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

Re: zed shebang and typo ?



On Fri, 29 Jan 2010 21:25:07 +0100
Julien Jehannet <julien@xxxxxxxx> wrote:
> I don't know if it's a reasonable demand to add a sheband in standard release?

It's easy and harmless (I hadn't quite realized it worked as a script).
We've used /bin/zsh elsewhere and that's often good enough these days.

I found an oddity:  I assumed zed needed to be run with zsh -i since it
uses zle, but it turns out someone (quite possibly me) fixed vared so it
can be run in a non-interactive shell.  If you *do* use the -i option,
however, you get output at the end along the lines of

../Functions/Misc/zed:zsh:100: use 'exit' to exit.
../Functions/Misc/zed:zsh:100: use 'exit' to exit.
../Functions/Misc/zed:zsh:100: use 'exit' to exit.
../Functions/Misc/zed:zsh:100: use 'exit' to exit.
../Functions/Misc/zed:zsh:100: use 'exit' to exit.
../Functions/Misc/zed:zsh:100: use 'exit' to exit.
../Functions/Misc/zed:zsh:100: use 'exit' to exit.
../Functions/Misc/zed:zsh:100: use 'exit' to exit.
../Functions/Misc/zed:zsh:100: use 'exit' to exit.

This is because it's hitting end-of-file.  That's fine in an interactive
shell, except that we have a "return" just before, which at top level
should act as an exit.  It doesn't because there's a test not to do that
in an interactive shell, which is reasonable for protecting an
interactive user, but shouldn't be necessary if reading from a script,
so I've changed that.  (Sourcing files still does the right thing.)

Feel free to argue that the "use 'exit' to exit" warning shouldn't apply
if !isset(SHINSTDIN), either.

> Another thing: zed script has maybe a typo inside that doesn't seem to
> get fixed in cvs
> (http://zsh.cvs.sourceforge.net/viewvc/*checkout*/zsh/zsh/Functions/Misc/zed).

Thanks, I don't know how that escaped.

Index: Functions/Misc/zed
===================================================================
RCS file: /cvsroot/zsh/zsh/Functions/Misc/zed,v
retrieving revision 1.11
diff -u -r1.11 zed
--- Functions/Misc/zed	29 Jan 2010 20:59:07 -0000	1.11
+++ Functions/Misc/zed	29 Jan 2010 21:18:21 -0000
@@ -1,4 +1,4 @@
-#
+#!/bin/zsh
 # zed
 #
 # No other shell could do this.
Index: Src/builtin.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/builtin.c,v
retrieving revision 1.236
diff -u -r1.236 builtin.c
--- Src/builtin.c	6 Nov 2009 22:38:48 -0000	1.236
+++ Src/builtin.c	29 Jan 2010 21:18:22 -0000
@@ -4577,7 +4577,8 @@
 	breaks = nump ? minimum(num,loops) : 1;
 	break;
     case BIN_RETURN:
-	if (isset(INTERACTIVE) || locallevel || sourcelevel) {
+	if ((isset(INTERACTIVE) && isset(SHINSTDIN))
+	    || locallevel || sourcelevel) {
 	    retflag = 1;
 	    breaks = loops;
 	    lastval = num;
-- 
Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/



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