Function tryRun

Runs a command, through the system's command shell interpreter, in typical shell-script style: Synchronously, with the command's stdout/in/err automatically forwarded through your program's stdout/in/err.

int tryRun (
  string command
);

int tryRun (
  Path workingDirectory,
  string command
);

Optionally takes a working directory to run the command from.

The command is echoed if scriptlikeEcho is true.

Returns

The error level the process exited with. Or -1 upon failure to start the process.

Example

Args cmd;
cmd ~= Path("some tool");
cmd ~= "-o";
cmd ~= Path(`dir/out file.txt`);
cmd ~= ["--abc", "--def", "-g"];
auto errLevel = Path("some working dir").run(cmd.data);