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

Re: 4.0.1: menucomplete quirk leaving extra characters behind

"Bart Schaefer" wrote:
> I'd say first let's just try it with readonly being a one-way trip, and
> see where we end up.

This also does the same for autoloadable but not yet loaded parameters; the
problem in that case is usually that turning attributes on or off is
meaningless rather than dangerous, and the typeset code is complicated
enough that anything that allows us to keep different cases together is
good news.

Then $* and $@ are made readonly.  As I reported, you can't set them
directly anyway; as Bart reported, you can only cause mischief by unsetting

Index: Doc/Zsh/builtins.yo
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/builtins.yo,v
retrieving revision 1.29
diff -u -r1.29 builtins.yo
--- Doc/Zsh/builtins.yo	2001/06/08 03:04:41	1.29
+++ Doc/Zsh/builtins.yo	2001/06/14 09:32:23
@@ -1192,7 +1192,9 @@
 The value is em(not) converted when assigned.
-The given var(name)s are marked readonly.
+The given var(name)s are marked readonly.  Note that if var(name) is a
+special parameter, the readonly attribute can be turned on, but cannot then
+be turned off.
 Tags the named parameters.  Tags have no special meaning to the shell.
Index: Doc/Zsh/params.yo
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/params.yo,v
retrieving revision 1.9
diff -u -r1.9 params.yo
--- Doc/Zsh/params.yo	2001/05/29 17:54:39	1.9
+++ Doc/Zsh/params.yo	2001/06/14 09:32:23
@@ -31,9 +31,11 @@
 In the parameter lists that follow, the mark `<S>' indicates that the
 parameter is special.
-Special parameters cannot have their type changed, and they stay special even
-if unset.  `<Z>' indicates that the parameter does not exist when the shell
-initializes in tt(sh) or tt(ksh) emulation mode.
+Special parameters cannot have their type changed or their
+readonly attribute turned off, and if a special parameter is unset, then
+later recreated, the special properties will be retained.  `<Z>' indicates
+that the parameter does not exist when the shell initializes in tt(sh) or
+tt(ksh) emulation mode.
 menu(Array Parameters)
 menu(Positional Parameters)
Index: Src/builtin.c
RCS file: /cvsroot/zsh/zsh/Src/builtin.c,v
retrieving revision 1.46
diff -u -r1.46 builtin.c
--- Src/builtin.c	2001/05/15 10:02:35	1.46
+++ Src/builtin.c	2001/06/14 09:32:23
@@ -1628,7 +1628,14 @@
 	if ((tc = chflags && chflags != (PM_EFLOAT|PM_FFLOAT)))
 	    usepm = 0;
-    if (tc){
+    /*
+     * Extra checks if converting the type of a parameter, or if
+     * trying to remove readonlyness.  It's dangerous doing either
+     * with a special or a parameter which isn't loaded yet (which
+     * may be special when it is loaded; we can't tell yet).
+     */
+    if (tc || ((usepm || newspecial) && (off & pm->flags & PM_READONLY))) {
 	if (pm->flags & PM_SPECIAL) {
 	    zerrnam(cname, "%s: can't change type of a special parameter",
 		    pname, 0);
Index: Src/params.c
RCS file: /cvsroot/zsh/zsh/Src/params.c,v
retrieving revision 1.48
diff -u -r1.48 params.c
--- Src/params.c	2001/05/31 09:44:00	1.48
+++ Src/params.c	2001/06/14 09:32:23
@@ -216,8 +216,8 @@
 #define IPDEF9F(A,B,C,D) {NULL,A,D|PM_ARRAY|PM_SPECIAL|PM_DONTIMPORT,BR((void *)B),SFN(arrvarsetfn),GFN(arrvargetfn),stdunsetfn,0,NULL,C,NULL,0}
 #define IPDEF9(A,B,C) IPDEF9F(A,B,C,0)
-IPDEF9("*", &pparams, NULL),
-IPDEF9("@", &pparams, NULL),
Peter Stephenson <pws@xxxxxxx>                  Software Engineer
CSR Ltd., Unit 300, Science Park, Milton Road,
Cambridge, CB4 0XL, UK                          Tel: +44 (0)1223 392070

The information transmitted is intended only for the person or
entity to which it is addressed and may contain confidential 
and/or privileged material. 
Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by 
persons or entities other than the intended recipient is 
If you received this in error, please contact the sender and 
delete the material from any computer.

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