about summary refs log tree commit diff
path: root/Src
diff options
context:
space:
mode:
Diffstat (limited to 'Src')
-rw-r--r--Src/exec.c51
-rw-r--r--Src/parse.c6
2 files changed, 30 insertions, 27 deletions
diff --git a/Src/exec.c b/Src/exec.c
index 9bbcf4979..3b0e936b4 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -2427,7 +2427,6 @@ execcmd(Estate state, int input, int output, int how, int last1)
     wordcode code;
     Wordcode beg = state->pc, varspc;
     FILE *oxtrerr = xtrerr, *newxtrerr = NULL;
-    LinkList restorelist = 0, removelist = 0;
 
     doneps4 = 0;
     redir = (wc_code(*state->pc) == WC_REDIR ? ecgetredirs(state) : NULL);
@@ -3360,9 +3359,9 @@ execcmd(Estate state, int input, int output, int how, int last1)
 		zcontext_restore();
 	    } else
 		redir_prog = NULL;
-
+	    
 	    lastval = execfuncdef(state, redir_prog);
-	}
+	} 
 	else if (type >= WC_CURSH) {
 	    if (last1 == 1)
 		do_exec = 1;
@@ -3375,6 +3374,7 @@ execcmd(Estate state, int input, int output, int how, int last1)
 	    } else
 		lastval = (execfuncs[type - WC_CURSH])(state, do_exec);
 	} else if (is_builtin || is_shfunc) {
+	    LinkList restorelist = 0, removelist = 0;
 	    /* builtin or shell function */
 
 	    if (!forked && ((cflags & BINF_COMMAND) ||
@@ -3424,6 +3424,29 @@ execcmd(Estate state, int input, int output, int how, int last1)
 		} else
 		    clearerr(stdout);
 	    }
+	    if (isset(PRINTEXITVALUE) && isset(SHINSTDIN) &&
+		lastval && !subsh) {
+#if defined(ZLONG_IS_LONG_LONG) && defined(PRINTF_HAS_LLD)
+		fprintf(stderr, "zsh: exit %lld\n", lastval);
+#else
+		fprintf(stderr, "zsh: exit %ld\n", (long)lastval);
+#endif
+		fflush(stderr);
+	    }
+
+	    if (do_exec) {
+		if (subsh)
+		    _exit(lastval);
+
+		/* If we are exec'ing a command, and we are not in a subshell, *
+		 * then check if we should save the history file.              */
+		if (isset(RCS) && interact && !nohistsave)
+		    savehistfile(NULL, 1, HFILE_USE_OPTIONS);
+		exit(lastval);
+	    }
+	    if (restorelist)
+		restore_params(restorelist, removelist);
+
 	} else {
 	    if (!forked)
 		setiparam("SHLVL", --shlvl);
@@ -3473,28 +3496,6 @@ execcmd(Estate state, int input, int output, int how, int last1)
 		execlist(state, 0, 1);
 	    }
 	}
-	if (isset(PRINTEXITVALUE) && isset(SHINSTDIN) &&
-	    lastval && !subsh) {
-#if defined(ZLONG_IS_LONG_LONG) && defined(PRINTF_HAS_LLD)
-	    fprintf(stderr, "zsh: exit %lld\n", lastval);
-#else
-	    fprintf(stderr, "zsh: exit %ld\n", (long)lastval);
-#endif
-	    fflush(stderr);
-	}
-
-	if (do_exec) {
-	    if (subsh)
-		_exit(lastval);
-
-	    /* If we are exec'ing a command, and we are not in a subshell, *
-	     * then check if we should save the history file.              */
-	    if (isset(RCS) && interact && !nohistsave)
-		savehistfile(NULL, 1, HFILE_USE_OPTIONS);
-	    exit(lastval);
-	}
-	if (restorelist)
-	    restore_params(restorelist, removelist);
     }
 
   err:
diff --git a/Src/parse.c b/Src/parse.c
index ffd25de9d..0b54a904d 100644
--- a/Src/parse.c
+++ b/Src/parse.c
@@ -1612,7 +1612,8 @@ par_funcdef(int *cmplx)
 	    num++;
 	    zshlex();
 	}
-	*cmplx = 1;
+	if (num > 0)
+	    *cmplx = 1;
 	ecbuf[parg] = ecused - parg; /*?*/
 	ecbuf[parg+1] = num;
     }
@@ -1896,7 +1897,8 @@ par_simple(int *cmplx, int nr)
 		    argc++;
 		    zshlex();
 		}
-		*cmplx = 1;
+		if (argc > 0)
+		    *cmplx = 1;
 		ecbuf[parg] = ecused - parg; /*?*/
 		ecbuf[parg+1] = argc;
 	    }