struct globals_var {
struct shparam shellparam; /* $@ current positional parameters */
struct redirtab *redirlist;
- int g_nullredirs;
int preverrout_fd; /* save fd2 before print debug if xflag is set. */
struct var *vartab[VTABSIZE];
struct var varinit[ARRAY_SIZE(varinit_data)];
#define G_var (*ash_ptr_to_globals_var)
#define shellparam (G_var.shellparam )
//#define redirlist (G_var.redirlist )
-#define g_nullredirs (G_var.g_nullredirs )
#define preverrout_fd (G_var.preverrout_fd)
#define vartab (G_var.vartab )
#define varinit (G_var.varinit )
};
struct redirtab {
struct redirtab *next;
- int nullredirs;
int pair_count;
struct two_fd_t two_fd[];
};
int newfd;
int copied_fd2 = -1;
- g_nullredirs++;
if (!redir) {
return;
}
sv->next = redirlist;
sv->pair_count = sv_pos;
redirlist = sv;
- sv->nullredirs = g_nullredirs - 1;
- g_nullredirs = 0;
while (sv_pos > 0) {
sv_pos--;
sv->two_fd[sv_pos].orig = sv->two_fd[sv_pos].copy = EMPTY;
struct redirtab *rp;
int i;
- if (--g_nullredirs >= 0 || redirlist == NULL)
+ if (redirlist == NULL)
return;
INT_OFF;
rp = redirlist;
}
}
redirlist = rp->next;
- g_nullredirs = rp->nullredirs;
free(rp);
INT_ON;
}
static void
clearredir(int drop)
{
- for (;;) {
- g_nullredirs = 0;
- if (!redirlist)
- break;
+ while (redirlist)
popredir(drop, /*restore:*/ 0);
- }
}
static int
if (!status) {
status = evaltree(n->nredir.n, flags & EV_TESTED);
}
- popredir(/*drop:*/ 0, /*restore:*/ 0 /* not sure */);
+ if (n->nredir.redirect)
+ popredir(/*drop:*/ 0, /*restore:*/ 0 /* not sure */);
goto setstatus;
case NCMD:
evalfn = evalcommand;
} /* switch */
out:
- popredir(/*drop:*/ cmd_is_exec, /*restore:*/ cmd_is_exec);
+ if (cmd->ncmd.redirect)
+ popredir(/*drop:*/ cmd_is_exec, /*restore:*/ cmd_is_exec);
if (lastarg) {
/* dsl: I think this is intended to be used to support
* '_' in 'vi' command mode during line editing...