summaryrefslogtreecommitdiff
path: root/Src
diff options
context:
space:
mode:
authorBart Schaefer <schaefer@ipost.com>2021-04-18 14:26:12 -0700
committerBart Schaefer <schaefer@ipost.com>2021-04-18 14:26:12 -0700
commit71b747567e350c5f849897c424ea76fd05b34ffe (patch)
tree71ac096df68a13309adf4abffcd6a31ebcc67200 /Src
parent82ff9f24f170eea7daa935fdaa09ab75a2f277ff (diff)
downloadzsh-71b747567e350c5f849897c424ea76fd05b34ffe.tar.gz
zsh-71b747567e350c5f849897c424ea76fd05b34ffe.zip
47704: POSIX export and readonly ignore "-p" when parameter names also appear
Diffstat (limited to 'Src')
-rw-r--r--Src/builtin.c8
-rw-r--r--Src/params.c4
2 files changed, 10 insertions, 2 deletions
diff --git a/Src/builtin.c b/Src/builtin.c
index 6d119f7a5..efa20607e 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -2615,7 +2615,12 @@ bin_typeset(char *name, char **argv, LinkList assigns, Options ops, int func)
int on = 0, off = 0, roff, bit = PM_ARRAY;
int i;
int returnval = 0, printflags = 0;
- int hasargs;
+ int hasargs = *argv != NULL || (assigns && firstnode(assigns));
+
+ /* POSIXBUILTINS is set for bash/ksh and both ignore -p with args */
+ if ((func == BIN_READONLY || func == BIN_EXPORT) &&
+ isset(POSIXBUILTINS) && hasargs)
+ ops->ind['p'] = 0;
/* hash -f is really the builtin `functions' */
if (OPT_ISSET(ops,'f'))
@@ -2695,7 +2700,6 @@ bin_typeset(char *name, char **argv, LinkList assigns, Options ops, int func)
/* -p0 treated as -p for consistency */
}
}
- hasargs = *argv != NULL || (assigns && firstnode(assigns));
if (!hasargs) {
int exclude = 0;
if (!OPT_ISSET(ops,'p')) {
diff --git a/Src/params.c b/Src/params.c
index 33bbc54f6..20dfb5b5f 100644
--- a/Src/params.c
+++ b/Src/params.c
@@ -5883,8 +5883,12 @@ printparamnode(HashNode hn, int printflags)
* don't.
*/
if (printflags & PRINT_POSIX_EXPORT) {
+ if (!(p->node.flags & PM_EXPORTED))
+ return;
printf("export ");
} else if (printflags & PRINT_POSIX_READONLY) {
+ if (!(p->node.flags & PM_READONLY))
+ return;
printf("readonly ");
} else if (locallevel && p->level >= locallevel) {
printf("typeset "); /* printf("local "); */