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 @@ -2708,13 +2708,14 @@ static int getenvMS(WindowInfo *window,
16 static int shellCmdMS(WindowInfo *window, DataValue *argList, int nArgs,
17 DataValue *result, char **errMsg)
19 - char stringStorage[2][TYPE_INT_STR_SIZE(int)], *cmdString, *inputString;
20 + char stringStorage[2][TYPE_INT_STR_SIZE(int)], *cmdString, *inputString = "";
23 + if (nArgs != 1 && nArgs != 2)
24 return wrongNArgsErr(errMsg);
25 if (!readStringArg(argList[0], &cmdString, stringStorage[0], errMsg))
27 - if (!readStringArg(argList[1], &inputString, stringStorage[1], errMsg))
29 + !readStringArg(argList[1], &inputString, stringStorage[1], errMsg))
32 /* Shell command execution requires that the macro be suspended, so
33 diff --quilt old/doc/help.etx new/doc/help.etx
36 @@ -2693,10 +2693,11 @@ Macro Subroutines
37 **set_cursor_pos( position )**
38 Set the cursor position for the current window.
40 -**shell_command( command, input_string )**
41 +**shell_command( command[, input_string] )**
42 Executes a shell command, feeding it input from input_string. On completion,
43 output from the command is returned as the function value, and the command's
44 - exit status is returned in the global variable $shell_cmd_status.
45 + exit status is returned in the global variable $shell_cmd_status. If the
46 + input_string is ommited or is "" the shell command get no input.
48 **split(string, separation_string [, search_type])**
49 Splits a string using the separator specified. Optionally the search_type