diff options
-rw-r--r-- | shell/ash.c | 21 |
1 files changed, 6 insertions, 15 deletions
diff --git a/shell/ash.c b/shell/ash.c index dc0f60747..dc26bc142 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
@@ -1951,7 +1951,6 @@ struct redirtab; | |||
1951 | struct globals_var { | 1951 | struct globals_var { |
1952 | struct shparam shellparam; /* $@ current positional parameters */ | 1952 | struct shparam shellparam; /* $@ current positional parameters */ |
1953 | struct redirtab *redirlist; | 1953 | struct redirtab *redirlist; |
1954 | int g_nullredirs; | ||
1955 | int preverrout_fd; /* save fd2 before print debug if xflag is set. */ | 1954 | int preverrout_fd; /* save fd2 before print debug if xflag is set. */ |
1956 | struct var *vartab[VTABSIZE]; | 1955 | struct var *vartab[VTABSIZE]; |
1957 | struct var varinit[ARRAY_SIZE(varinit_data)]; | 1956 | struct var varinit[ARRAY_SIZE(varinit_data)]; |
@@ -1960,7 +1959,6 @@ extern struct globals_var *const ash_ptr_to_globals_var; | |||
1960 | #define G_var (*ash_ptr_to_globals_var) | 1959 | #define G_var (*ash_ptr_to_globals_var) |
1961 | #define shellparam (G_var.shellparam ) | 1960 | #define shellparam (G_var.shellparam ) |
1962 | //#define redirlist (G_var.redirlist ) | 1961 | //#define redirlist (G_var.redirlist ) |
1963 | #define g_nullredirs (G_var.g_nullredirs ) | ||
1964 | #define preverrout_fd (G_var.preverrout_fd) | 1962 | #define preverrout_fd (G_var.preverrout_fd) |
1965 | #define vartab (G_var.vartab ) | 1963 | #define vartab (G_var.vartab ) |
1966 | #define varinit (G_var.varinit ) | 1964 | #define varinit (G_var.varinit ) |
@@ -5216,7 +5214,6 @@ struct two_fd_t { | |||
5216 | }; | 5214 | }; |
5217 | struct redirtab { | 5215 | struct redirtab { |
5218 | struct redirtab *next; | 5216 | struct redirtab *next; |
5219 | int nullredirs; | ||
5220 | int pair_count; | 5217 | int pair_count; |
5221 | struct two_fd_t two_fd[]; | 5218 | struct two_fd_t two_fd[]; |
5222 | }; | 5219 | }; |
@@ -5295,7 +5292,6 @@ redirect(union node *redir, int flags) | |||
5295 | int newfd; | 5292 | int newfd; |
5296 | int copied_fd2 = -1; | 5293 | int copied_fd2 = -1; |
5297 | 5294 | ||
5298 | g_nullredirs++; | ||
5299 | if (!redir) { | 5295 | if (!redir) { |
5300 | return; | 5296 | return; |
5301 | } | 5297 | } |
@@ -5317,8 +5313,6 @@ redirect(union node *redir, int flags) | |||
5317 | sv->next = redirlist; | 5313 | sv->next = redirlist; |
5318 | sv->pair_count = sv_pos; | 5314 | sv->pair_count = sv_pos; |
5319 | redirlist = sv; | 5315 | redirlist = sv; |
5320 | sv->nullredirs = g_nullredirs - 1; | ||
5321 | g_nullredirs = 0; | ||
5322 | while (sv_pos > 0) { | 5316 | while (sv_pos > 0) { |
5323 | sv_pos--; | 5317 | sv_pos--; |
5324 | sv->two_fd[sv_pos].orig = sv->two_fd[sv_pos].copy = EMPTY; | 5318 | sv->two_fd[sv_pos].orig = sv->two_fd[sv_pos].copy = EMPTY; |
@@ -5430,7 +5424,7 @@ popredir(int drop, int restore) | |||
5430 | struct redirtab *rp; | 5424 | struct redirtab *rp; |
5431 | int i; | 5425 | int i; |
5432 | 5426 | ||
5433 | if (--g_nullredirs >= 0 || redirlist == NULL) | 5427 | if (redirlist == NULL) |
5434 | return; | 5428 | return; |
5435 | INT_OFF; | 5429 | INT_OFF; |
5436 | rp = redirlist; | 5430 | rp = redirlist; |
@@ -5452,7 +5446,6 @@ popredir(int drop, int restore) | |||
5452 | } | 5446 | } |
5453 | } | 5447 | } |
5454 | redirlist = rp->next; | 5448 | redirlist = rp->next; |
5455 | g_nullredirs = rp->nullredirs; | ||
5456 | free(rp); | 5449 | free(rp); |
5457 | INT_ON; | 5450 | INT_ON; |
5458 | } | 5451 | } |
@@ -5467,12 +5460,8 @@ popredir(int drop, int restore) | |||
5467 | static void | 5460 | static void |
5468 | clearredir(int drop) | 5461 | clearredir(int drop) |
5469 | { | 5462 | { |
5470 | for (;;) { | 5463 | while (redirlist) |
5471 | g_nullredirs = 0; | ||
5472 | if (!redirlist) | ||
5473 | break; | ||
5474 | popredir(drop, /*restore:*/ 0); | 5464 | popredir(drop, /*restore:*/ 0); |
5475 | } | ||
5476 | } | 5465 | } |
5477 | 5466 | ||
5478 | static int | 5467 | static int |
@@ -8573,7 +8562,8 @@ evaltree(union node *n, int flags) | |||
8573 | if (!status) { | 8562 | if (!status) { |
8574 | status = evaltree(n->nredir.n, flags & EV_TESTED); | 8563 | status = evaltree(n->nredir.n, flags & EV_TESTED); |
8575 | } | 8564 | } |
8576 | popredir(/*drop:*/ 0, /*restore:*/ 0 /* not sure */); | 8565 | if (n->nredir.redirect) |
8566 | popredir(/*drop:*/ 0, /*restore:*/ 0 /* not sure */); | ||
8577 | goto setstatus; | 8567 | goto setstatus; |
8578 | case NCMD: | 8568 | case NCMD: |
8579 | evalfn = evalcommand; | 8569 | evalfn = evalcommand; |
@@ -9645,7 +9635,8 @@ evalcommand(union node *cmd, int flags) | |||
9645 | } /* switch */ | 9635 | } /* switch */ |
9646 | 9636 | ||
9647 | out: | 9637 | out: |
9648 | popredir(/*drop:*/ cmd_is_exec, /*restore:*/ cmd_is_exec); | 9638 | if (cmd->ncmd.redirect) |
9639 | popredir(/*drop:*/ cmd_is_exec, /*restore:*/ cmd_is_exec); | ||
9649 | if (lastarg) { | 9640 | if (lastarg) { |
9650 | /* dsl: I think this is intended to be used to support | 9641 | /* dsl: I think this is intended to be used to support |
9651 | * '_' in 'vi' command mode during line editing... | 9642 | * '_' in 'vi' command mode during line editing... |