diff options
-rw-r--r-- | shell/ash.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/shell/ash.c b/shell/ash.c index 42e14cbc8..c96ec939e 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
@@ -6128,7 +6128,9 @@ struct backcmd { /* result of evalbackcmd */ | |||
6128 | }; | 6128 | }; |
6129 | 6129 | ||
6130 | /* These forward decls are needed to use "eval" code for backticks handling: */ | 6130 | /* These forward decls are needed to use "eval" code for backticks handling: */ |
6131 | #define EV_EXIT 01 /* exit after evaluating tree */ | 6131 | /* flags in argument to evaltree */ |
6132 | #define EV_EXIT 01 /* exit after evaluating tree */ | ||
6133 | #define EV_TESTED 02 /* exit status is checked; ignore -e flag */ | ||
6132 | static int evaltree(union node *, int); | 6134 | static int evaltree(union node *, int); |
6133 | 6135 | ||
6134 | static void FAST_FUNC | 6136 | static void FAST_FUNC |
@@ -8345,10 +8347,6 @@ commandcmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) | |||
8345 | static void *funcblock; /* block to allocate function from */ | 8347 | static void *funcblock; /* block to allocate function from */ |
8346 | static char *funcstring_end; /* end of block to allocate strings from */ | 8348 | static char *funcstring_end; /* end of block to allocate strings from */ |
8347 | 8349 | ||
8348 | /* flags in argument to evaltree */ | ||
8349 | #define EV_EXIT 01 /* exit after evaluating tree */ | ||
8350 | #define EV_TESTED 02 /* exit status is checked; ignore -e flag */ | ||
8351 | |||
8352 | static const uint8_t nodesize[N_NUMBER] ALIGN1 = { | 8350 | static const uint8_t nodesize[N_NUMBER] ALIGN1 = { |
8353 | [NCMD ] = SHELL_ALIGN(sizeof(struct ncmd)), | 8351 | [NCMD ] = SHELL_ALIGN(sizeof(struct ncmd)), |
8354 | [NPIPE ] = SHELL_ALIGN(sizeof(struct npipe)), | 8352 | [NPIPE ] = SHELL_ALIGN(sizeof(struct npipe)), |
@@ -12491,6 +12489,12 @@ expandstr(const char *ps) | |||
12491 | return stackblock(); | 12489 | return stackblock(); |
12492 | } | 12490 | } |
12493 | 12491 | ||
12492 | static inline int | ||
12493 | parser_eof(void) | ||
12494 | { | ||
12495 | return tokpushback && lasttoken == TEOF; | ||
12496 | } | ||
12497 | |||
12494 | /* | 12498 | /* |
12495 | * Execute a command or commands contained in a string. | 12499 | * Execute a command or commands contained in a string. |
12496 | */ | 12500 | */ |
@@ -12526,7 +12530,7 @@ evalstring(char *s, int flags) | |||
12526 | while ((n = parsecmd(0)) != NODE_EOF) { | 12530 | while ((n = parsecmd(0)) != NODE_EOF) { |
12527 | int i; | 12531 | int i; |
12528 | 12532 | ||
12529 | i = evaltree(n, flags); | 12533 | i = evaltree(n, flags & ~(parser_eof() ? 0 : EV_EXIT)); |
12530 | if (n) | 12534 | if (n) |
12531 | status = i; | 12535 | status = i; |
12532 | popstackmark(&smark); | 12536 | popstackmark(&smark); |
@@ -13671,7 +13675,7 @@ int ash_main(int argc UNUSED_PARAM, char **argv) | |||
13671 | // if (!sflag) g_parsefile->pf_fd = -1; | 13675 | // if (!sflag) g_parsefile->pf_fd = -1; |
13672 | // ^^ not necessary since now we special-case fd 0 | 13676 | // ^^ not necessary since now we special-case fd 0 |
13673 | // in is_hidden_fd() to not be considered "hidden fd" | 13677 | // in is_hidden_fd() to not be considered "hidden fd" |
13674 | evalstring(minusc, 0); | 13678 | evalstring(minusc, sflag ? 0 : EV_EXIT); |
13675 | } | 13679 | } |
13676 | 13680 | ||
13677 | if (sflag || minusc == NULL) { | 13681 | if (sflag || minusc == NULL) { |