1 Subject: shell_command(): make "input_string" argument optional
3 This simple patch makes the "input_string" of the shell_command() macro
4 optional and defaults it to "".
9 source/macro.c | 7 ++++---
10 2 files changed, 7 insertions(+), 5 deletions(-)
12 diff --quilt old/source/macro.c new/source/macro.c
13 --- old/source/macro.c
14 +++ new/source/macro.c
15 @@ -2711,17 +2711,18 @@ static int getenvMS(WindowInfo *window,
18 static int shellCmdMS(WindowInfo *window, DataValue *argList, int nArgs,
19 DataValue *result, char **errMsg)
21 - char stringStorage[2][TYPE_INT_STR_SIZE(int)], *cmdString, *inputString;
22 + char stringStorage[2][TYPE_INT_STR_SIZE(int)], *cmdString, *inputString = "";
25 + if (nArgs != 1 && nArgs != 2)
26 return wrongNArgsErr(errMsg);
27 if (!readStringArg(argList[0], &cmdString, stringStorage[0], errMsg))
29 - if (!readStringArg(argList[1], &inputString, stringStorage[1], errMsg))
31 + !readStringArg(argList[1], &inputString, stringStorage[1], errMsg))
34 /* Shell command execution requires that the macro be suspended, so
35 this subroutine can't be run if macro execution can't be interrupted */
36 if (MacroRunWindow()->macroCmdData == NULL) {
37 diff --quilt old/doc/help.etx new/doc/help.etx
40 @@ -2691,14 +2691,15 @@ Macro Subroutines
43 **set_cursor_pos( position )**
44 Set the cursor position for the current window.
46 -**shell_command( command, input_string )**
47 +**shell_command( command[, input_string] )**
48 Executes a shell command, feeding it input from input_string. On completion,
49 output from the command is returned as the function value, and the command's
50 - exit status is returned in the global variable $shell_cmd_status.
51 + exit status is returned in the global variable $shell_cmd_status. If the
52 + input_string is ommited or is "" the shell command get no input.
54 **split(string, separation_string [, search_type])**
55 Splits a string using the separator specified. Optionally the search_type
56 argument can specify how the separation_string is interpreted. The default
57 is "literal". The returned value is an array with keys beginning at 0.