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

Re: 4.3.4-dev-4 and 4.2.6-dev-2 available



Vincent Lefevre wrote:
> The man page concerning setopt and unsetopt (with no arguments) should
> be clarified. I've never understood what "setopt" and "unsetopt" give
> exactly: why are some versions with "no" listed in setopt and some of
> them in unsetopt?

You're right, this isn't documented anywhere sensible.

> It seems that setopt gives the differences from the default (but what
> is the default?). However:

It's the one for the current emulation.

> courge:~> zsh -f -c setopt
> norcs
> shinstdin
> 
> Why shinstdin?

It's set automatically by the shell if it determines that the shell will
use standard input.  However...

> This seems to contradict the zshoptions(1) man page.

Do you mean the description of SHIN_STDIN?  It does indeed imply
(although not *quite* explicitly state, since the logic is a little
tortuous) this will be off if -c is given, whereas it isn't.

It's not entirely clear to me if this is intentional or not.  The code
for -c explicitly sets the option to 0, but then the code later
explicitly sets it to 1 if there is no argument list.  The former code
appears to be redundant since at that point the option would be zero, so
this is fishy.(*)  So I've gone with the documentation, since the
basic rationale (the commands being executed aren't being read from
stdin) is clear.

There's a side effect, reflected in the test patch: commands after -c
now get line numbers in error messages as scripts do.  I consider this a
feature.

(*) Actually, it's possible that the user had explicitly requested
shinstdin before -c.  But it didn't reset shinstdin if that was
explicitly requested after -c.  Further, the other case of picking up
commands, a script argument, doesn't reset shinstdin.  So I still don't
like it.

Index: Doc/Zsh/builtins.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/builtins.yo,v
retrieving revision 1.99
diff -u -r1.99 builtins.yo
--- Doc/Zsh/builtins.yo	5 Oct 2007 19:31:03 -0000	1.99
+++ Doc/Zsh/builtins.yo	11 Dec 2007 14:48:15 -0000
@@ -1137,7 +1137,8 @@
 ifzman(zmanref(zshoptions))\
 ifnzman(noderef(Options))\
 .  Flags may be specified by name using the tt(-o) option. If no option
-name is supplied with tt(-o), the current option states are printed.
+name is supplied with tt(-o), the current option states are printed:  see
+the description of tt(setopt) below for more information on the format.
 With tt(PLUS()o) they are printed in a form that can be used as input
 to the shell.
 
@@ -1180,8 +1181,23 @@
 item(tt(setopt) [ {tt(PLUS())|tt(-)}var(options) | \
 {tt(PLUS())|tt(-)}tt(o) var(option_name) ] [ var(name) ... ])(
 Set the options for the shell.  All options specified either
-with flags or by name are set.  If no arguments are supplied,
-the names of all options currently set are printed.
+with flags or by name are set.
+
+If no arguments are supplied, the names of all options currently set are
+printed.  The form is chosen so as to minimize the differences from the
+default options for the current emulation (the default emulation being
+native tt(zsh), shown as tt(<Z>) in
+ifzman(zmanref(zshoptions))\
+ifnzman(noderef(Description of Options))).
+Options that are on by default for the emulation are
+shown with the prefix tt(no) only if they are off, while other options are
+shown without the prefix tt(no) and only if they are on.  In addition to
+options changed from the default state by the user, any options activated
+automatically by the shell (for example, tt(SHIN_STDIN) or tt(INTERACTIVE))
+will be shown in the list.  The format is further modified by the option
+tt(KSH_OPTION_PRINT), however the rationale for choosing options with
+or without the tt(no) prefix remains the same in this case.
+
 If the tt(-m) flag is given the arguments are taken as patterns
 (which should be quoted to protect them from filename expansion), and all
 options with names matching these patterns are set.
Index: Src/init.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/init.c,v
retrieving revision 1.79
diff -u -r1.79 init.c
--- Src/init.c	26 Nov 2007 10:27:59 -0000	1.79
+++ Src/init.c	11 Dec 2007 14:48:16 -0000
@@ -272,7 +272,6 @@
 		/* -c command */
 		cmd = *argv;
 		opts[INTERACTIVE] &= 1;
-		opts[SHINSTDIN] = 0;
 		scriptname = ztrdup("zsh");
 	    } else if (**argv == 'o') {
 		if (!*++*argv)
@@ -334,7 +333,7 @@
 	}
 	while (*argv)
 	    zaddlinknode(paramlist, ztrdup(*argv++));
-    } else
+    } else if (!cmd)
 	opts[SHINSTDIN] = 1;
     if(isset(SINGLECOMMAND))
 	opts[INTERACTIVE] &= 1;
Index: Test/A01grammar.ztst
===================================================================
RCS file: /cvsroot/zsh/zsh/Test/A01grammar.ztst,v
retrieving revision 1.15
diff -u -r1.15 A01grammar.ztst
--- Test/A01grammar.ztst	29 May 2007 14:50:29 -0000	1.15
+++ Test/A01grammar.ztst	11 Dec 2007 14:48:16 -0000
@@ -490,7 +490,7 @@
 
   $ZTST_testdir/../Src/zsh -f -c "'"
 1:Parse error on inline command causes non-zero exit status
-?zsh: unmatched '
+?zsh:1: unmatched '
 
   $ZTST_testdir/../Src/zsh -f NonExistentScript
 127q:Non-existent script causes exit status 127

-- 
Peter Stephenson <pws@xxxxxxx>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070



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