fix motifless build, keep original LIBS variable
[nedit-bw.git] / shell_command-make-input-parameter-optional.patch
blob654d4848204511a55f102ea0d930084edd4a4d74
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 "".
6 ---
8 doc/help.etx | 5 +++--
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 @@ -2709,13 +2709,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 = "";
22 - if (nArgs != 2)
23 + if (nArgs != 1 && nArgs != 2)
24 return wrongNArgsErr(errMsg);
25 if (!readStringArg(argList[0], &cmdString, stringStorage[0], errMsg))
26 return False;
27 - if (!readStringArg(argList[1], &inputString, stringStorage[1], errMsg))
28 + if (nArgs == 2 &&
29 + !readStringArg(argList[1], &inputString, stringStorage[1], errMsg))
30 return False;
32 /* Shell command execution requires that the macro be suspended, so
33 diff --quilt old/doc/help.etx new/doc/help.etx
34 --- old/doc/help.etx
35 +++ 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