summaryrefslogtreecommitdiff
path: root/Src/exec.c
diff options
context:
space:
mode:
Diffstat (limited to 'Src/exec.c')
-rw-r--r--Src/exec.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/Src/exec.c b/Src/exec.c
index c0ee527b7..352615c83 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -471,9 +471,10 @@ zexecve(char *pth, char **argv, char **newenvp)
if ((fd = open(pth, O_RDONLY|O_NOCTTY)) >= 0) {
argv0 = *argv;
*argv = pth;
+ execvebuf[0] = '\0';
ct = read(fd, execvebuf, POUNDBANGLIMIT);
close(fd);
- if (ct > 0) {
+ if (ct >= 0) {
if (execvebuf[0] == '#') {
if (execvebuf[1] == '!') {
for (t0 = 0; t0 != ct; t0++)
@@ -2264,7 +2265,7 @@ addvars(Estate state, Wordcode pc, int addflags)
* is implicitly scoped.
*/
flags = (!(addflags & ADDVAR_RESTORE) &&
- locallevel > 0 && isset(WARNCREATEGLOBAL)) ?
+ locallevel > forklevel && isset(WARNCREATEGLOBAL)) ?
ASSPM_WARN_CREATE : 0;
xtr = isset(XTRACE);
if (xtr) {
@@ -2784,6 +2785,11 @@ execcmd(Estate state, int input, int output, int how, int last1)
* arguments before and no command substitution
* has provided a status.
*/
+ if (badcshglob == 1) {
+ zerr("no match");
+ lastval = 1;
+ return;
+ }
cmdoutval = use_cmdoutval ? lastval : 0;
if (varspc)
addvars(state, varspc, 0);
@@ -3225,7 +3231,7 @@ execcmd(Estate state, int input, int output, int how, int last1)
* not terminal, unless `file' is a terminal. */
if (nullexec == 1 && fn->fd1 == 0 &&
isset(SHINSTDIN) && interact && !zleactive)
- init_io();
+ init_io(NULL);
break;
case REDIR_CLOSE:
if (fn->varid) {
@@ -3475,10 +3481,10 @@ execcmd(Estate state, int input, int output, int how, int last1)
restore_queue_signals(q);
} else if (is_builtin || is_shfunc) {
LinkList restorelist = 0, removelist = 0;
+ int do_save = 0;
/* builtin or shell function */
- if (!forked && varspc) {
- int do_save = 0;
+ if (!forked) {
if (isset(POSIXBUILTINS)) {
/*
* If it's a function or special builtin --- save
@@ -3497,7 +3503,7 @@ execcmd(Estate state, int input, int output, int how, int last1)
if ((cflags & BINF_COMMAND) || !assign)
do_save = 1;
}
- if (do_save)
+ if (do_save && varspc)
save_params(state, varspc, &restorelist, &removelist);
}
if (varspc) {
@@ -3643,6 +3649,8 @@ execcmd(Estate state, int input, int output, int how, int last1)
}
dont_queue_signals();
lastval = execbuiltin(args, assigns, (Builtin) hn);
+ if (do_save & BINF_COMMAND)
+ errflag &= ~ERRFLAG_ERROR;
restore_queue_signals(q);
fflush(stdout);
if (save[1] == -2) {