summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBart Schaefer <schaefer@zsh.org>2025-02-15 14:29:51 -0800
committerBart Schaefer <schaefer@zsh.org>2025-02-15 14:29:51 -0800
commit8701313c615394654f47586c9a4961ac8893bf5b (patch)
tree07151727382d4ec7750bd280ad33c9195fb1a5b5
parent2e08ea1aef9d47b2919d7e5bd2cb6bb01c8029fc (diff)
downloadzsh-8701313c615394654f47586c9a4961ac8893bf5b.tar.gz
zsh-8701313c615394654f47586c9a4961ac8893bf5b.zip
53363: permit "typeset -n +m pattern"
Also fix spurious error printing the value of a read-only named reference
-rw-r--r--ChangeLog7
-rw-r--r--Src/builtin.c7
2 files changed, 10 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 990509ae1..05aa89c88 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2025-02-15 Bart Schaefer <schaefer@zsh.org>
+
+ * 53363: Src/builtin.c: permit "typeset -n +m pattern"
+
+ * unposted: Src/builtin.c: fix spurious error printing the value
+ of a read-only named reference
+
2025-02-13 Oliver Kiddle <opk@zsh.org>
* 53358: Completion/Zsh/Command/_typeset: adapt completion to
diff --git a/Src/builtin.c b/Src/builtin.c
index 2fab73b24..6bdaddff0 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -2254,7 +2254,7 @@ typeset_single(char *cname, char *pname, Param pm, int func,
/* It seems as though these checks should not be specific to
* PM_NAMEREF, but changing that changes historic behavior */
((on & PM_NAMEREF) != (pm->node.flags & PM_NAMEREF) ||
- (asg && (pm->node.flags & PM_NAMEREF)))) {
+ (asg && (pm->node.flags & PM_NAMEREF))) && !OPT_ISSET(ops,'p')) {
zerrnam(cname, "%s: read-only %s", pname,
(pm->node.flags & PM_NAMEREF) ? "reference" : "variable");
return NULL;
@@ -3053,12 +3053,11 @@ bin_typeset(char *name, char **argv, LinkList assigns, Options ops, int func)
/* With the -m option, treat arguments as glob patterns */
if (OPT_ISSET(ops,'m')) {
if (!OPT_ISSET(ops,'p')) {
- if (on & PM_NAMEREF) {
+ if ((on & PM_NAMEREF) && OPT_MINUS(ops,'m')) {
/* It's generally unwise to mass-change the types of
* parameters, but for namerefs it would be fatal */
unqueue_signals();
- zerrnam(name, "%cm not allowed with -n",
- (OPT_PLUS(ops,'m') ? '+' : '-'));
+ zerrnam(name, "-m not allowed with -n");
return 1;
}
if (!(on|roff))