Invoke a command in the system command-line shell
Usage
shell(
command,
args = character(),
print = interactive(),
wd = getwd(),
stderrFile = NULL,
stdoutFile = NULL,
stderrToStdout = FALSE,
returnStdout = FALSE
)
Arguments
- command
character(1)
. Name of program to run.- args
character
. Arguments passed tocommand
.logical(1)
. Whether to print (echo) the commands to the console.- wd
character(1)
. Working directory path inside shell session.- stdoutFile, stderrFile
character(1)
orNULL
. File path to log stdout and/or stderr. Disabled when setNULL
.- stderrToStdout
logical(1)
. Whether to redirect standard error (stderr) to standard output (stdout). Similar to2>&1
in POSIX or&>
in Bash.- returnStdout
logical(1)
. Whether to return stdout as a character vector, split by"\n"
.
See also
base::system2()
, our previously used legacy approach.