Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Shorthand To Execute Unix Commands From The C# REPL  #14249

@nkosi23

Description

@nkosi23

have just discovered the C# REPL shipping with mono and I am seriously interested in making it our main scripting language for all our sysadmin tasks on Unix.

However, what is missing to make it possible is a lightweight shorthand to execute OS binaries and read the input of the command.

Something like: uexec ls (for unix exec), that could be used like:
uxec ls | grep interesting_file.

The command uexec would implicitly return an IEnumerable ready to be consumed. The command uexec would treat the first string as the name of the command and any other word as additional arguments to that command. Strings can optionally be put within double quotes to indicate that whitespaces should not be treated as parameter separators.

The only relatively challenging part would be implementing pipelining. But I think this can be done quite easily by creating a list of all the commands of the pipeline initially, and then executing them with uexec recursively while passing them the previous input.

I think this is all that is needed to have a powerful C# based scripting environment in Unix. If people install python for their scripting, why not mono. This rich tooling is what sets mono apart from .net core (putting aside the amazingly powerful and flexible compiler options of mono, even the garbage collector algorithm can be changed).

The other features of the REPL such as the ability to load dll and invoke classes make it seamless to scale scripts and refactor them as libraries.

I think this shorthand has a huge potential, while the implementation of uexec may actually be quite simple to achieve. Unfortunately I do not think I will have the bandwidth to dig into the mono codebase and become familiar / productive with it before quite some time (at least a few months) so I'm posting this here in case someone with a mature understansing of the codebase and an already configured development environment feels inspired to give it a jab.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions