shell
- function, command
- The shell() function executes its arguments in a UNIX shell and returns the output. The shell exit code is returned in the result.
- The shell command also executes its arguments in a UNIX shell. The shell exit code is available in item 1 of the result and any output as item 2 of the result.
- New in 1.74:
- • Enhanced the shell command / function. You can now include optional named parameters (a property list) at the end of parameters, including:
includeErrors – causes the standard error stream to be included in the output if set to True
notify – an object to notify when the shell task has completed (defaults to ‘me’ if not given and a message is specified)
message – message to send to the notify object when the task completes (defaults to “ShellDone” if not specified)
command – the command to execute (this allows a single property list parameter to be used)
get shell(command:theCmd, includeStderr:YES)
shell "grep -i 'foo' */*", notify:me, message:"grepComplete"
If notify and/or message is specified, the shell command/function will return immediately and the script will proceed. When the shell task finishes the notification message will be sent to the notify object. The notification message includes 3 parameters: the output, the exit status, and the input command (in order to distinguish between different callbacks). If the script run completes before the task has finished, the result is undefined.
If multiple shell calls are made asynchronously, the resulting callback order may be different than the order in which the calls were made. A faster-running command may complete before a slower command that was called earlier.
- Related: process, shellCommand