mirror of
https://github.com/mirror/make.git
synced 2026-08-19 16:33:28 +08:00
[SV 63667] In .POSIX, use shell flags -c when ignoring errors
* src/variable.c (lookup_variable_for_file): New function to retrieve a variable assignment in a file context. * src/variable.h (lookup_variable_for_file): Declare it. * src/job.c (construct_command_argv): Look up .SHELLFLAGS. If .POSIX is set and we're using the default value, choose -c if we're ignoring errors else choose -ec. (construct_command_argv_internal): Ditto. * tests/scripts/targets/POSIX: Add tests.
This commit is contained in:
@@ -7,12 +7,52 @@ $details = "";
|
||||
|
||||
# Ensure turning on .POSIX enables the -e flag for the shell
|
||||
|
||||
run_make_test(qq!
|
||||
run_make_test(q!
|
||||
.POSIX:
|
||||
all: ; \@#HELPER# -q fail 1; true
|
||||
all: ; @#HELPER# -q fail 1; #HELPER# out hello
|
||||
!,
|
||||
'', "#MAKE#: *** [#MAKEFILE#:3: all] Error 1\n", 512);
|
||||
|
||||
# But explicit settings must still take precedence
|
||||
|
||||
run_make_test(q!
|
||||
.POSIX:
|
||||
all: ; @-#HELPER# -q fail 1; #HELPER# out hello
|
||||
.SHELLFLAGS = -c
|
||||
!,
|
||||
'', "hello");
|
||||
|
||||
run_make_test(q!
|
||||
.POSIX:
|
||||
all: ; @-#HELPER# -q fail 1; #HELPER# out hello
|
||||
all: .SHELLFLAGS = -c
|
||||
!,
|
||||
'', "hello");
|
||||
|
||||
# SV 63667: We shouldn't add -e to sh if errors are ignored
|
||||
|
||||
run_make_test(q!
|
||||
.POSIX:
|
||||
all: ; @-#HELPER# -q fail 1; #HELPER# out hello
|
||||
!,
|
||||
'', "hello\n");
|
||||
|
||||
# But explicit settings must still take precedence
|
||||
|
||||
run_make_test(q!
|
||||
.POSIX:
|
||||
all: ; @-#HELPER# -q fail 1; #HELPER# out hello
|
||||
.SHELLFLAGS = -ec
|
||||
!,
|
||||
'', "#MAKE#: [#MAKEFILE#:3: all] Error 1 (ignored)\n");
|
||||
|
||||
run_make_test(q!
|
||||
.POSIX:
|
||||
all: ; @-#HELPER# -q fail 1; #HELPER# out hello
|
||||
all: .SHELLFLAGS = -ec
|
||||
!,
|
||||
'', "#MAKE#: [#MAKEFILE#:3: all] Error 1 (ignored)\n");
|
||||
|
||||
# User settings must override .POSIX
|
||||
# In the standard .POSIX must be the first thing in the makefile
|
||||
# but we relax that rule in GNU Make.
|
||||
|
||||
Reference in New Issue
Block a user