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

Re: "setopt noexec" and interactive shells

On Mar 27,  8:12pm, Zefram wrote:
} Oh, and whichever way it's implemented in the end, it'll have to be
} documented.

I played around a bit with the most recent patch (13756) as adjusted to
remove the isatty(0) test.  It had some unexpected side-effects, one of
which was that `zpty' commands were not executed (because `interactive'
is not set in the subshell whose i/o is the pty slave).

So I've concluded that preserving but selectively ignoring the state of
the option is at least as bad as silently resetting it.

The other alternative that Zefram suggested was noisily refusing to change
the option:

Index: Src/options.c
--- Src/options.c	2001/02/28 17:05:08	1.22
+++ Src/options.c	2001/03/30 05:24:38
@@ -647,6 +647,9 @@
 	    for (s = rparams; *s; s++)
+    } else if(!force && optno == EXECOPT && !value && interact) {
+	/* cannot set noexec when interactive */
+	return -1;
     } else if(!force && (optno == INTERACTIVE || optno == SHINSTDIN ||
 	    optno == SINGLECOMMAND)) {
 	if (opts[optno] == value)

With the above patch, `zsh -n' can still give you a useless prompt, but
`set -n' etc. within the shell will complain:

zagzig% set -n
set: can't change option: -n
zagzig% setopt noexec
setopt: can't change option: noexec

Any remaining objections?

Index: Doc/Zsh/options.yo
--- Doc/Zsh/options.yo	2001/03/19 02:32:20	1.47
+++ Doc/Zsh/options.yo	2001/03/30 06:35:08
@@ -374,6 +374,8 @@
 item(tt(EXEC) (tt(PLUS()n), ksh: tt(PLUS()n)) <D>)(
 Do execute commands.  Without this option, commands are
 read and checked for syntax errors, but not executed.
+This option cannot be turned off in an interactive shell,
+except when `tt(-n)' is supplied to the shell at startup.
 cindex(globbing, extended)

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