Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: [BUG] 'command' + special built-in exits shell on error



On Dec 23, 11:53am, Martijn Dekker wrote:
}
} My bug report is that zsh still exits even when 'command' is used, and
} even when emulating sh.

When not emulating sh, "command" can't be used in front of a special
builtin at all -- in zsh mode it always forces the command to be NOT
built-in, i.e., it's implicitly "command -p".

Consequently we only care about POSIXBUILTINS mode.


diff --git a/Src/exec.c b/Src/exec.c
index acc867c..f14fc27 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -3475,10 +3475,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 +3497,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 +3643,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) {



Messages sorted by: Reverse Date, Date, Thread, Author