Process
Struct · namespace System
struct ProcessRuns other programs and reads environment variables (static functions).
int code = Process.Run("clang -c a.c -o a.o");var text = Process.RunCapture("clang --version"); // the text the program writes to stdoutStatic methods
Section titled “Static methods”| Name | Description |
|---|---|
Run |
Runs a command line through the system shell (sh or cmd.exe) and waits for it. |
IsWindows |
True on Windows. |
IsMacOS |
True on macOS: the file that names the version of the system exists (/System/Library/CoreServices/SystemVersion.plist). |
RunCapture |
Runs a command line through the system shell and returns everything the program writes to stdout. |
GetEnv |
The value of the environment variable name. |
static int Run(StringSlice command)Runs a command line through the system shell (sh or cmd.exe) and waits for it. What the program wrote
before is written out first, so that the output of the command comes after it.
Returns the exit code of the program, or -1 if it could not be started.
IsWindows
Section titled “IsWindows”static bool IsWindows()True on Windows. The environment variable OS is not always passed on (e.g. by an MSYS2 login shell), so the system’s cmd.exe is looked for as well.
IsMacOS
Section titled “IsMacOS”static bool IsMacOS()True on macOS: the file that names the version of the system exists (/System/Library/CoreServices/SystemVersion.plist). False on Windows, Linux, WebAssembly and AmigaOS.
Since 0.32
RunCapture
Section titled “RunCapture”static Optional<string> RunCapture(StringSlice command)Runs a command line through the system shell and returns everything the program writes to stdout.
Returns nothing (null) if the program could not be started.
GetEnv
Section titled “GetEnv”static Optional<string> GetEnv(StringSlice name)The value of the environment variable name.
Returns nothing (null) if it is not set.