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

Re: "setopt noexec" and interactive shells



On Mar 25, 10:51pm, Bart Schaefer wrote:
}
} Any comments on this patch?

Ahem.  I have my own comment:  It doesn't work.  I missed another spot
where EXECOPT is tested.  Critique the following patch instead.


Index: Src/exec.c
===================================================================
RCS file: /extra/cvsroot/zsh/zsh-3.1/Src/exec.c,v
retrieving revision 1.128
diff -c -r1.128 exec.c
--- Src/exec.c	2001/03/24 22:19:24	1.128
+++ Src/exec.c	2001/03/25 22:59:12
@@ -1639,7 +1639,7 @@
     char *text;
     int save[10];
     int fil, dfil, is_cursh, type, do_exec = 0, i, htok = 0;
-    int nullexec = 0, assign = 0, forked = 0;
+    int nullexec = 0, assign = 0, forked = 0, execopt;
     int is_shfunc = 0, is_builtin = 0, is_exec = 0;
     /* Various flags to the command. */
     int cflags = 0, checked = 0;
@@ -1648,6 +1648,7 @@
     Wordcode beg = state->pc, varspc;
     FILE *oxtrerr = xtrerr;
 
+    execopt = !(unset(EXECOPT) && (unset(INTERACTIVE) || !isatty(0)));
     doneps4 = 0;
     redir = (wc_code(*state->pc) == WC_REDIR ? ecgetredirs(state) : NULL);
     if (wc_code(*state->pc) == WC_ASSIGN) {
@@ -2092,7 +2093,7 @@
 		zwarn("writing redirection not allowed in restricted mode", NULL, 0);
 		execerr();
 	    }
-	    if (unset(EXECOPT))
+	    if (!execopt)
 		continue;
 	    switch(fn->type) {
 	    case REDIR_HERESTR:
@@ -2218,7 +2219,7 @@
 	    fputc('\n', xtrerr);
 	    fflush(xtrerr);
 	}
-    } else if (isset(EXECOPT) && !errflag) {
+    } else if (execopt && !errflag) {
 	/*
 	 * We delay the entersubsh() to here when we are exec'ing
 	 * the current shell (including a fake exec to run a builtin then

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   



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