summaryrefslogtreecommitdiff
path: root/shell/hush.c
diff options
context:
space:
mode:
authorDenys Vlasenko2021-09-07 02:23:51 +0200
committerDenys Vlasenko2021-09-07 02:25:52 +0200
commite53c7dbafc78948e5c0d8d8ccb0bdcd9f936c62e (patch)
tree909286fc381d47fba921621afb809a84997815fc /shell/hush.c
parentf415e21a7dce1d4f4b760fddfaba85c551681e11 (diff)
downloadbusybox-e53c7dbafc78948e5c0d8d8ccb0bdcd9f936c62e.zip
busybox-e53c7dbafc78948e5c0d8d8ccb0bdcd9f936c62e.tar.gz
hush: fix set -n to act immediately, not just after run_list()
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell/hush.c')
-rw-r--r--shell/hush.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/shell/hush.c b/shell/hush.c
index 27092c1..5fafa32 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -9898,7 +9898,8 @@ static int run_list(struct pipe *pi)
#if ENABLE_HUSH_LOOPS
G.flag_break_continue = 0;
#endif
- rcode = r = run_pipe(pi); /* NB: rcode is a smalluint, r is int */
+ rcode = r = G.o_opt[OPT_O_NOEXEC] ? 0 : run_pipe(pi);
+ /* NB: rcode is a smalluint, r is int */
if (r != -1) {
/* We ran a builtin, function, or group.
* rcode is already known
@@ -10137,7 +10138,10 @@ static int set_mode(int state, char mode, const char *o_opt)
int idx;
switch (mode) {
case 'n':
- G.o_opt[OPT_O_NOEXEC] = state;
+ /* set -n has no effect in interactive shell */
+ /* Try: while set -n; do echo $-; done */
+ if (!G_interactive_fd)
+ G.o_opt[OPT_O_NOEXEC] = state;
break;
case 'x':
IF_HUSH_MODE_X(G_x_mode = state;)