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

Re: set - $foo resets set -x



Andrey Borzenkov wrote:
>     /* Obsolescent sh compatibility: set - is the same as set +xv *
>      * and set - args is the same as set +xv -- args              */
>     if (*args && **args == '-' && !args[0][1]) {
>         dosetopt(VERBOSE, 0, 0);
>         dosetopt(XTRACE, 0, 0);
>         if (!args[1])
>             return 0;
>     }
> 
> Anyone remembers the reasons for that? May be we can at least relax it if 
> running in emulate zsh mode?

I'm inclined to agree, since zsh's native emulation tends to remove the
worst idiocies from prehistory, and currently it doesn't even seem to be
documented...

Index: Doc/Zsh/builtins.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/builtins.yo,v
retrieving revision 1.86
diff -u -r1.86 builtins.yo
--- Doc/Zsh/builtins.yo	24 Jul 2006 22:00:20 -0000	1.86
+++ Doc/Zsh/builtins.yo	19 Sep 2006 16:51:40 -0000
@@ -1160,6 +1160,10 @@
 If no arguments and no `tt(-)tt(-)' are given, then the names and values of
 all parameters are printed on the standard output.  If the only argument is
 `tt(PLUS())', the names of all parameters are printed.
+
+For historical reasons, `tt(set -)' is treated as `tt(set +xv)'
+and `tt(set -) var(args)' as `tt(set +xv --) var(args)' when in
+any other emulation mode than zsh's native mode.
 )
 module(setcap)(zsh/cap)
 findex(setopt)
Index: Src/builtin.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/builtin.c,v
retrieving revision 1.162
diff -u -r1.162 builtin.c
--- Src/builtin.c	10 Sep 2006 19:11:54 -0000	1.162
+++ Src/builtin.c	19 Sep 2006 16:51:41 -0000
@@ -535,7 +535,7 @@
 
     /* Obsolescent sh compatibility: set - is the same as set +xv *
      * and set - args is the same as set +xv -- args              */
-    if (*args && **args == '-' && !args[0][1]) {
+    if (emulation != EMULATE_ZSH && *args && **args == '-' && !args[0][1]) {
 	dosetopt(VERBOSE, 0, 0);
 	dosetopt(XTRACE, 0, 0);
 	if (!args[1])

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


To access the latest news from CSR copy this link into a web browser:  http://www.csr.com/email_sig.php



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