diff options
author | Bart Schaefer <schaefer@zsh.org> | 2025-02-12 20:03:07 -0800 |
---|---|---|
committer | Bart Schaefer <schaefer@zsh.org> | 2025-02-12 20:03:07 -0800 |
commit | 7a54b36fa88aa35f44c42715503f716a1612e3b7 (patch) | |
tree | c22a9b24ce65a49f33f1730724ab5ad350ee736f /Src | |
parent | 51cb3f0f83649b7ca59d62447519f7ea53fb5ec4 (diff) | |
download | zsh-7a54b36fa88aa35f44c42715503f716a1612e3b7.tar.gz zsh-7a54b36fa88aa35f44c42715503f716a1612e3b7.zip |
53348: Revise handling of incompatible typeset options when used with -n
Diffstat (limited to 'Src')
-rw-r--r-- | Src/builtin.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/Src/builtin.c b/Src/builtin.c index 18d74b09e..2fab73b24 100644 --- a/Src/builtin.c +++ b/Src/builtin.c @@ -2707,10 +2707,18 @@ bin_typeset(char *name, char **argv, LinkList assigns, Options ops, int func) on |= bit; else if (OPT_PLUS(ops,optval)) 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 ((on|off) & ~(PM_READONLY|PM_UPPER)) { - zwarnnam(name, "no other attributes allowed with -n"); + if ((on|off) & ~(PM_READONLY|PM_UPPER|PM_HIDEVAL)) { + /* zwarnnam(name, "no other attributes allowed with -n"); */ return 1; } 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 * parameters, but for namerefs it would be fatal */ unqueue_signals(); - zerrnam(name, "invalid reference"); + zerrnam(name, "%cm not allowed with -n", + (OPT_PLUS(ops,'m') ? '+' : '-')); return 1; } if (!(on|roff)) |