diff options
author | Paul Smith <psmith@gnu.org> | 2022-02-06 16:22:40 -0500 |
---|---|---|
committer | Paul Smith <psmith@gnu.org> | 2022-02-06 18:46:32 -0500 |
commit | 342a9bb54b36fc054c59cec961322a025634229f (patch) | |
tree | f02b40de85608da79b8b7af1c6fdeef136781cda /src/function.c | |
parent | 6761122be03a65e8b013b5dd902bbea3a87d09e3 (diff) | |
download | make-git-342a9bb54b36fc054c59cec961322a025634229f.tar.gz |
Don't write $(shell ...) stdout to stderr on failure
If a $(shell ...) invocation failed due to a command-not-found error,
make wrote the stdout of that shell to our stderr for some reason.
That seems very wrong.
If the command's stderr was not redirected then its output would have
already been written to its stderr, and if it was redirected then we
shouldn't take it upon ourselves to force it to go to stderr!
* src/function.c (func_shell_base): Append shell stdout even if the
shell command failed.
* tests/run_make_tests.pl: Determine the error generated for
command-not-found situations.
* tests/scripts/functions/shell: Verify that redirecting stderr to
stdout will behave properly if the command is not found.
Diffstat (limited to 'src/function.c')
-rw-r--r-- | src/function.c | 22 |
1 files changed, 4 insertions, 18 deletions
diff --git a/src/function.c b/src/function.c index d7c13923..9add8f65 100644 --- a/src/function.c +++ b/src/function.c @@ -2012,24 +2012,10 @@ func_shell_base (char *o, char **argv, int trim_newlines) } shell_function_pid = 0; - /* shell_completed() will set shell_function_completed to 1 when the - child dies normally, or to -1 if it dies with status 127, which is - most likely an exec fail. */ - - if (shell_function_completed == -1) - { - /* This likely means that the execvp failed, so we should just - write the error message in the pipe from the child. */ - fputs (buffer, stderr); - fflush (stderr); - } - else - { - /* The child finished normally. Replace all newlines in its output - with spaces, and put that in the variable output buffer. */ - fold_newlines (buffer, &i, trim_newlines); - o = variable_buffer_output (o, buffer, i); - } + /* Replace all newlines in the command's output with spaces, and put that + in the variable output buffer. */ + fold_newlines (buffer, &i, trim_newlines); + o = variable_buffer_output (o, buffer, i); free (buffer); } |