Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
RE: PATCH: "typeset -m" plays havoc
- X-seq: zsh-workers 12806
- From: "Andrej Borsenkow" <Andrej.Borsenkow@xxxxxxxxxxxxxx>
- To: <zsh-workers@xxxxxxxxxxxxxx>
- Subject: RE: PATCH: "typeset -m" plays havoc
- Date: Thu, 14 Sep 2000 20:55:16 +0400
- Importance: Normal
- In-reply-to: <1000914154206.ZM12447@xxxxxxxxxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxxxxxx; run by ezmlm
> Don't try this:
>
> zsh% splat() { typeset -m \* }
> zsh% splat
>
> The result is that all non-readonly/non-special parameters get stomped on,
> which leaves zsh in a pretty sorry state.
>
> The behavior up to 3.1.5 or so was that `-m' implied the equivalent of `-g',
> so I think the following is the most expedient patch. Peter?
>
What happens in case of
splat() { typeset -F -m \* }
??
Currently it creates local floating point parameters and then breaks on first
special one (in may case it is cdpath). With this patch, won't it silently
change type of global parameters?
Also, consider:
bor@itsrm2% splat () {typeset cdpath}
bor@itsrm2% splat
If I can believe manual:
For each remaining NAME that refers to a parameter that is set, the
name and value of the parameter are printed in the form of an
assignment. Nothing is printed for newly-created parameters, or
if any attribute flags listed below are given. Using `+' instead
of minus to introduce an attribute turns it off.
In our case cdpath is definitely set; but what we get is creation of local
cdpath.
The suggested patch seems to take care of the both. It is on top of Bart's.
Peter?
Index: Src/builtin.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/builtin.c,v
retrieving revision 1.32
diff -u -r1.32 builtin.c
--- Src/builtin.c 2000/09/14 15:55:00 1.32
+++ Src/builtin.c 2000/09/14 16:54:31
@@ -1800,7 +1800,7 @@
Asgment asg;
Patprog pprog;
char *optstr = TYPESET_OPTSTR;
- int on = 0, off = 0, roff, bit = PM_ARRAY;
+ int on = 0, off = 0, ron, roff, bit = PM_ARRAY;
int i;
int returnval = 0, printflags = 0;
@@ -1816,6 +1816,7 @@
on |= bit;
else if (ops[STOUC(*optstr)] == 2)
off |= bit;
+ ron = on;
roff = off;
/* Sanity checks on the options. Remove conficting options. */
@@ -1858,7 +1859,8 @@
return 0;
}
- if ((!ops['g'] && !ops['x']) || ops['g'] == 2 || *name == 'l' ||
+ if ((!ops['g'] && !ops['x'] && (ron || roff))
+ || ops['g'] == 2 || *name == 'l' ||
!isset(GLOBALEXPORT))
on |= PM_LOCAL;
@@ -1942,7 +1944,6 @@
/* With the -m option, treat arguments as glob patterns */
if (ops['m']) {
- on &= ~PM_LOCAL;
while ((asg = getasg(*argv++))) {
LinkList pmlist = newlinklist();
LinkNode pmnode;
Messages sorted by:
Reverse Date,
Date,
Thread,
Author