[SV 28092] Preserve the exit status of the $(shell...) function.

Add a new variable .SHELLSTATUS which holds the exit status of the
last-invoked shell function or != assignment.

* NEWS, doc/make.texi: Document the change.
* function.c (shell_completed, msdos_openpipe, func_shell_base): Add
shell_completed() to handle the completion of the shell, by setting
.SHELLSTATUS.  Call it where needed.
* job.c (child_handler): Call shell_completed().
* tests/scripts/functions/shell: Add tests for .SHELLSTATUS.
This commit is contained in:
Paul Smith
2015-07-12 21:03:24 -04:00
parent c18b23f7b2
commit 43181f1f82
6 changed files with 62 additions and 21 deletions

View File

@@ -134,7 +134,7 @@ char *patsubst_expand_pat (char *o, const char *text, const char *pattern,
const char *replace_percent);
char *patsubst_expand (char *o, const char *text, char *pattern, char *replace);
char *func_shell_base (char *o, char **argv, int trim_newlines);
void shell_completed (int exit_code, int exit_sig);
/* expand.c */
char *recursively_expand_for_file (struct variable *v, struct file *file);