Function std.process.spawnShell
A variation on spawnProcess
that runs the given command through
the current user's preferred command interpreter (aka. shell).
The string
is passed verbatim to the shell, and is therefore
subject to its rules about command structure, argument/filename quoting
and escaping of special characters.
The path to the shell executable is always command
/bin/sh
on POSIX, and
determined by the userShell
function on Windows.
In all other respects this function works just like
.
Please refer to the spawnProcess
spawnProcess
documentation for descriptions
of the other function parameters, the return value and any exceptions
that may be thrown.
// Run the command/program "foo" on the file named "my file.txt", and
// redirect its output into foo.log.
auto pid = spawnShell(foo "my file.txt" > foo.log
);
wait(pid);
Prototypes
Pid spawnShell( const(char[]) command, File stdin = stdin, File stdout = stdout, File stderr = stderr, const(string[string]) env = cast(const(string[string]))null, Config config = cast(Config)0, const(char[]) workDir = null ) @trusted; Pid spawnShell( const(char[]) command, const(string[string]) env, Config config = cast(Config)0, const(char[]) workDir = null ) @trusted;
See also
escapeShellCommand
, which may be helpful in constructing a
properly quoted and escaped shell command line for the current platform.
Authors
Lars Tandle Kyllingstad, Steven Schveighoffer, Vladimir Panteleev