diff options
Diffstat (limited to 'Src/exec.c')
-rw-r--r-- | Src/exec.c | 52 |
1 files changed, 41 insertions, 11 deletions
diff --git a/Src/exec.c b/Src/exec.c index f16cfd391..5ad957f98 100644 --- a/Src/exec.c +++ b/Src/exec.c @@ -2346,7 +2346,7 @@ execsubst(LinkList strs) { if (strs) { prefork(strs, esprefork); - if (esglob) { + if (esglob && !errflag) { LinkList ostrs = strs; globlist(strs, 0); strs = ostrs; @@ -3867,8 +3867,10 @@ getoutputfile(char *cmd, char **eptr) int fd; char *s; - if (thisjob == -1) + if (thisjob == -1){ + zerr("process substitution %s cannot be used here", cmd); return NULL; + } if (!(prog = parsecmd(cmd, eptr))) return NULL; if (!(nam = gettempname(NULL, 0))) @@ -3939,11 +3941,13 @@ namedpipe(void) char *tnam = gettempname(NULL, 1); # ifdef HAVE_MKFIFO - if (mkfifo(tnam, 0600) < 0) + if (mkfifo(tnam, 0600) < 0){ # else - if (mknod(tnam, 0010600, 0) < 0) + if (mknod(tnam, 0010600, 0) < 0){ # endif + zerr("failed to create named pipe: %s, %e", tnam, errno); return NULL; + } return tnam; } #endif /* ! PATH_DEV_FD && HAVE_FIFOS */ @@ -3966,9 +3970,10 @@ getproc(char *cmd, char **eptr) #ifndef PATH_DEV_FD int fd; - - if (thisjob == -1) + if (thisjob == -1) { + zerr("process substitution %s cannot be used here", cmd); return NULL; + } if (!(pnam = namedpipe())) return NULL; if (!(prog = parsecmd(cmd, eptr))) @@ -3993,8 +3998,10 @@ getproc(char *cmd, char **eptr) #else /* PATH_DEV_FD */ int pipes[2], fd; - if (thisjob == -1) + if (thisjob == -1) { + zerr("process substitution %s cannot be used here", cmd); return NULL; + } pnam = hcalloc(strlen(PATH_DEV_FD) + 6); if (!(prog = parsecmd(cmd, eptr))) return NULL; @@ -4234,8 +4241,13 @@ execfuncdef(Estate state, UNUSED(int do_exec)) plen = nprg * sizeof(wordcode); len = plen + (npats * sizeof(Patprog)) + nstrs; - if (htok && names) + if (htok && names) { execsubst(names); + if (errflag) { + state->pc = end; + return 1; + } + } while (!names || (s = (char *) ugetnode(names))) { if (!names) { @@ -4291,8 +4303,13 @@ execfuncdef(Estate state, UNUSED(int do_exec)) end += *state->pc++; args = ecgetlist(state, *state->pc++, EC_DUPTOK, &htok); - if (htok && args) + if (htok && args) { execsubst(args); + if (errflag) { + state->pc = end; + return 1; + } + } if (!args) args = newlinklist(); @@ -4597,7 +4614,7 @@ doshfunc(Shfunc shfunc, LinkList doshargs, int noreturnval) char *name = shfunc->node.nam; int flags = shfunc->node.flags, ooflags; char *fname = dupstring(name); - int obreaks, saveemulation, restore_sticky; + int obreaks, ocontflag, oloops, saveemulation, restore_sticky; Eprog prog; struct funcstack fstack; static int oflags; @@ -4609,7 +4626,9 @@ doshfunc(Shfunc shfunc, LinkList doshargs, int noreturnval) pushheap(); oargv0 = NULL; - obreaks = breaks;; + obreaks = breaks; + ocontflag = contflag; + oloops = loops; if (trap_state == TRAP_STATE_PRIMED) trap_return--; oldlastval = lastval; @@ -4797,6 +4816,17 @@ doshfunc(Shfunc shfunc, LinkList doshargs, int noreturnval) opts[XTRACE] = saveopts[XTRACE]; opts[PRINTEXITVALUE] = saveopts[PRINTEXITVALUE]; opts[LOCALOPTIONS] = saveopts[LOCALOPTIONS]; + opts[LOCALLOOPS] = saveopts[LOCALLOOPS]; + } + + if (opts[LOCALLOOPS]) { + if (contflag) + zwarn("`continue' active at end of function scope"); + if (breaks) + zwarn("`break' active at end of function scope"); + breaks = obreaks; + contflag = ocontflag; + loops = oloops; } endtrapscope(); |