mirror of
https://git.savannah.gnu.org/git/make.git
synced 2024-12-29 08:09:02 +00:00
43181f1f82
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.
47 lines
1 KiB
Perl
47 lines
1 KiB
Perl
# -*-perl-*-
|
|
|
|
$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');
|
|
|
|
# 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
|
|
if ($all_tests) {
|
|
run_make_test(q!
|
|
FOO := $(shell echo '#')
|
|
foo: ; echo '$(FOO)'
|
|
!,
|
|
'', "#\n");
|
|
}
|
|
|
|
# Test shells inside exported environment variables.
|
|
# This is the test that fails if we try to put make exported variables into
|
|
# the environment for a $(shell ...) call.
|
|
run_make_test('
|
|
export HI = $(shell echo hi)
|
|
.PHONY: all
|
|
all: ; @echo $$HI
|
|
','','hi');
|
|
|
|
1;
|