diff options
author | Ron Yorston <rmy@pobox.com> | 2024-04-20 16:08:09 +0100 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2024-04-20 16:08:09 +0100 |
commit | 356bfacef7da39052d404e2db166996cf7b74d4d (patch) | |
tree | ecfb1fdec1ea3dcd5ff8a1b4010e322404b6e1d8 | |
parent | ec3bd5c462717a6cd1668f536c8aab9d76ea04b0 (diff) | |
download | busybox-w32-356bfacef7da39052d404e2db166996cf7b74d4d.tar.gz busybox-w32-356bfacef7da39052d404e2db166996cf7b74d4d.tar.bz2 busybox-w32-356bfacef7da39052d404e2db166996cf7b74d4d.zip |
make: skip shell -e option when running commands
POSIX says, regarding execution of commands:
The execution line shall then be executed by a shell as if it
were passed as the argument to the system() interface, except
that if errors are not being ignored then the shell -e option
shall also be in effect.
As a non-POSIX extension, skip the use of the -e option. This is
how GNU make and BSD make behave.
(GitHub issue #409)
-rw-r--r-- | miscutils/make.c | 3 | ||||
-rwxr-xr-x | testsuite/make.tests | 7 |
2 files changed, 8 insertions, 2 deletions
diff --git a/miscutils/make.c b/miscutils/make.c index 87f17aad7..970919ddc 100644 --- a/miscutils/make.c +++ b/miscutils/make.c | |||
@@ -2217,7 +2217,7 @@ docmds(struct name *np, struct cmd *cp) | |||
2217 | if (sdomake) { | 2217 | if (sdomake) { |
2218 | // Get the shell to execute it | 2218 | // Get the shell to execute it |
2219 | int status; | 2219 | int status; |
2220 | char *cmd = !signore ? auto_concat("set -e;", q) : q; | 2220 | char *cmd = !signore && posix ? auto_concat("set -e;", q) : q; |
2221 | 2221 | ||
2222 | target = np; | 2222 | target = np; |
2223 | status = system(cmd); | 2223 | status = system(cmd); |
@@ -2233,7 +2233,6 @@ docmds(struct name *np, struct cmd *cp) | |||
2233 | diagnostic("failed to build '%s'", np->n_name); | 2233 | diagnostic("failed to build '%s'", np->n_name); |
2234 | estat |= MAKE_FAILURE; | 2234 | estat |= MAKE_FAILURE; |
2235 | free(command); | 2235 | free(command); |
2236 | free(cmd); | ||
2237 | break; | 2236 | break; |
2238 | } else if (doinclude) { | 2237 | } else if (doinclude) { |
2239 | warning("failed to build '%s'", np->n_name); | 2238 | warning("failed to build '%s'", np->n_name); |
diff --git a/testsuite/make.tests b/testsuite/make.tests index 1fc95a8d2..c512fbdaa 100755 --- a/testsuite/make.tests +++ b/testsuite/make.tests | |||
@@ -497,6 +497,13 @@ test.b: | |||
497 | ' | 497 | ' |
498 | cd .. || exit 1; rm -rf make.tempdir 2>/dev/null | 498 | cd .. || exit 1; rm -rf make.tempdir 2>/dev/null |
499 | 499 | ||
500 | # Don't use the shell -e option when running commands. | ||
501 | testing "make no shell -e option when running commands" \ | ||
502 | "make -f -" "OK\n" "" ' | ||
503 | target: | ||
504 | @false; echo OK | ||
505 | ' | ||
506 | |||
500 | # An empty original suffix indicates that every word should have | 507 | # An empty original suffix indicates that every word should have |
501 | # the new suffix added. If neither suffix is provided the words | 508 | # the new suffix added. If neither suffix is provided the words |
502 | # remain unchanged. | 509 | # remain unchanged. |