summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPaul Smith <psmith@gnu.org>2015-07-12 21:03:24 -0400
committerPaul Smith <psmith@gnu.org>2015-07-12 21:03:24 -0400
commit43181f1f8241c74f68d4ff85e567c418b128c569 (patch)
tree192c596b49846c8fa99235198865a01775c85d18 /tests
parentc18b23f7b249fb0ef17593b1641831fc05a56027 (diff)
[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.
Diffstat (limited to 'tests')
-rw-r--r--tests/scripts/functions/shell19
1 files changed, 17 insertions, 2 deletions
diff --git a/tests/scripts/functions/shell b/tests/scripts/functions/shell
index 723cd0ed..4702b096 100644
--- a/tests/scripts/functions/shell
+++ b/tests/scripts/functions/shell
@@ -4,11 +4,26 @@ $description = 'Test the $(shell ...) function.';
$details = '';
+# Test standard shell
+run_make_test('.PHONY: all
+OUT := $(shell echo hi)
+all: ; @echo $(OUT)
+ ','','hi');
# Test shells inside rules.
run_make_test('.PHONY: all
all: ; @echo $(shell echo hi)
-','','hi');
+ ','','hi');
+
+# Verify .SHELLSTATUS
+run_make_test('.PHONY: all
+PRE := $(.SHELLSTATUS)
+$(shell exit 0)
+OK := $(.SHELLSTATUS)
+$(shell exit 1)
+BAD := $(.SHELLSTATUS)
+all: ; @echo PRE=$(PRE) OK=$(OK) BAD=$(BAD)
+ ','','PRE= OK=0 BAD=1');
# Test unescaped comment characters in shells. Savannah bug #20513
@@ -27,6 +42,6 @@ run_make_test('
export HI = $(shell echo hi)
.PHONY: all
all: ; @echo $$HI
-','','hi');
+ ','','hi');
1;