mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-09-02 10:01:11 +02:00
53348: Revise handling of incompatible typeset options when used with -n
This commit is contained in:
parent
51cb3f0f83
commit
7a54b36fa8
4 changed files with 24 additions and 8 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
2025-02-12 Bart Schaefer <schaefer@zsh.org>
|
||||||
|
|
||||||
|
* 53348: Doc/Zsh/builtins.yo, Src/builtin.c, Test/K01nameref.ztst:
|
||||||
|
Revise handling of incompatible typeset options when used with -n
|
||||||
|
|
||||||
2025-02-04 Jun-ichi Takimoto <takimoto-j@kba.biglobe.ne.jp>
|
2025-02-04 Jun-ichi Takimoto <takimoto-j@kba.biglobe.ne.jp>
|
||||||
|
|
||||||
* unposted: Doc/Makefile.in, Etc/Makefile.in: remove a few more
|
* unposted: Doc/Makefile.in, Etc/Makefile.in: remove a few more
|
||||||
|
|
|
@ -2052,8 +2052,10 @@ cindex(named reference)
|
||||||
cindex(reference, named)
|
cindex(reference, named)
|
||||||
The flag tt(-n) creates a em(named reference) to another parameter.
|
The flag tt(-n) creates a em(named reference) to another parameter.
|
||||||
The second parameter need not exist at the time the reference is
|
The second parameter need not exist at the time the reference is
|
||||||
created. Only tt(-g), tt(-u), and tt(-r) may be used in conjunction with
|
created. Only the tt(-H), tt(-g), and tt(-r) flags may be used in
|
||||||
tt(-n). The var(name) so created may not be an array element nor use
|
conjunction with tt(-n), having their usual meanings. The tt(-u)
|
||||||
|
flag is special and may be applied to alter the scope of the reference.
|
||||||
|
The var(name) so created may not be an array element nor use
|
||||||
a subscript, but the var(value) assigned may be any valid parameter
|
a subscript, but the var(value) assigned may be any valid parameter
|
||||||
name syntax, even a subscripted array element (including an associative
|
name syntax, even a subscripted array element (including an associative
|
||||||
array element) or an array slice, which is evaluated when the named
|
array element) or an array slice, which is evaluated when the named
|
||||||
|
@ -2286,7 +2288,7 @@ special tt(PATH) parameter is not altered in any way. It is also possible
|
||||||
to create a local parameter using `tt(typeset +h )var(special)', where the
|
to create a local parameter using `tt(typeset +h )var(special)', where the
|
||||||
local copy of var(special) will retain its special properties regardless of
|
local copy of var(special) will retain its special properties regardless of
|
||||||
having the tt(-h) attribute. Global special parameters loaded from shell
|
having the tt(-h) attribute. Global special parameters loaded from shell
|
||||||
modules (currently those in tt(zsh/mapfile) and tt(zsh/parameter)) are
|
modules (for example, those in tt(zsh/mapfile) and tt(zsh/parameter)) are
|
||||||
automatically given the tt(-h) attribute to avoid name clashes.
|
automatically given the tt(-h) attribute to avoid name clashes.
|
||||||
)
|
)
|
||||||
item(tt(-H))(
|
item(tt(-H))(
|
||||||
|
@ -2349,7 +2351,7 @@ flag has a different meaning when used with tt(-f); see above.
|
||||||
item(tt(-u))(
|
item(tt(-u))(
|
||||||
Convert the result to upper case whenever the parameter is expanded.
|
Convert the result to upper case whenever the parameter is expanded.
|
||||||
The value is em(not) converted when assigned.
|
The value is em(not) converted when assigned.
|
||||||
This flag has a different meaning when used with tt(-f); see above.
|
This flag has different meanings when used with tt(-f) or tt(-n); see above.
|
||||||
)
|
)
|
||||||
item(tt(-x))(
|
item(tt(-x))(
|
||||||
Mark for automatic export to the environment of subsequently
|
Mark for automatic export to the environment of subsequently
|
||||||
|
|
|
@ -2707,10 +2707,18 @@ bin_typeset(char *name, char **argv, LinkList assigns, Options ops, int func)
|
||||||
on |= bit;
|
on |= bit;
|
||||||
else if (OPT_PLUS(ops,optval))
|
else if (OPT_PLUS(ops,optval))
|
||||||
off |= bit;
|
off |= bit;
|
||||||
|
else
|
||||||
|
continue;
|
||||||
|
if (OPT_MINUS(ops,'n')) {
|
||||||
|
if ((on|off) & ~(PM_READONLY|PM_UPPER|PM_HIDEVAL)) {
|
||||||
|
zwarnnam(name, "-%c not allowed with -n", optval);
|
||||||
|
/* return 1; */
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (OPT_MINUS(ops,'n')) {
|
if (OPT_MINUS(ops,'n')) {
|
||||||
if ((on|off) & ~(PM_READONLY|PM_UPPER)) {
|
if ((on|off) & ~(PM_READONLY|PM_UPPER|PM_HIDEVAL)) {
|
||||||
zwarnnam(name, "no other attributes allowed with -n");
|
/* zwarnnam(name, "no other attributes allowed with -n"); */
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
on |= PM_NAMEREF;
|
on |= PM_NAMEREF;
|
||||||
|
@ -3049,7 +3057,8 @@ bin_typeset(char *name, char **argv, LinkList assigns, Options ops, int func)
|
||||||
/* It's generally unwise to mass-change the types of
|
/* It's generally unwise to mass-change the types of
|
||||||
* parameters, but for namerefs it would be fatal */
|
* parameters, but for namerefs it would be fatal */
|
||||||
unqueue_signals();
|
unqueue_signals();
|
||||||
zerrnam(name, "invalid reference");
|
zerrnam(name, "%cm not allowed with -n",
|
||||||
|
(OPT_PLUS(ops,'m') ? '+' : '-'));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (!(on|roff))
|
if (!(on|roff))
|
||||||
|
|
|
@ -853,7 +853,7 @@ F:previously this could create an infinite recursion and crash
|
||||||
|
|
||||||
typeset -nm foo=bar
|
typeset -nm foo=bar
|
||||||
1:create nameref by pattern match not allowed
|
1:create nameref by pattern match not allowed
|
||||||
*?*typeset:1: invalid reference
|
*?*typeset:1: -m not allowed with -n
|
||||||
|
|
||||||
#
|
#
|
||||||
# The following tests are run in interactive mode, using PS1 as an
|
# The following tests are run in interactive mode, using PS1 as an
|
||||||
|
|
Loading…
Reference in a new issue