summaryrefslogtreecommitdiff
path: root/Src/params.c
diff options
context:
space:
mode:
authorBarton E. Schaefer <schaefer@zsh.org>2016-10-24 07:14:39 -0700
committerBarton E. Schaefer <schaefer@zsh.org>2016-10-24 07:14:39 -0700
commit0f5e670cde5f844680a20f986786249dfe983584 (patch)
treef912a4991610294666f2ec708dff1d87a58ea0b5 /Src/params.c
parent71dd0ab62ecf67e3a4a60749e9f5b1cfc9ac0ec4 (diff)
downloadzsh-0f5e670cde5f844680a20f986786249dfe983584.tar.gz
zsh-0f5e670cde5f844680a20f986786249dfe983584.zip
"typeset -p" uses "export" commands or the "-g" option for parameters that are not local to the current scope
Diffstat (limited to 'Src/params.c')
-rw-r--r--Src/params.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/Src/params.c b/Src/params.c
index 1418021aa..3084b1ffe 100644
--- a/Src/params.c
+++ b/Src/params.c
@@ -5225,7 +5225,7 @@ printparamvalue(Param p, int printflags)
{
char *t, **u;
- if (p->node.flags & PM_AUTOLOAD) {
+ if ((p->node.flags & PM_EXPORTED) && !p->env) {
putchar('\n');
return;
}
@@ -5312,9 +5312,13 @@ printparamnode(HashNode hn, int printflags)
*/
printflags |= PRINT_NAMEONLY;
}
+ else if (p->node.flags & PM_EXPORTED)
+ printflags |= PRINT_NAMEONLY;
else
return;
}
+ if (p->node.flags & PM_AUTOLOAD)
+ printflags |= PRINT_NAMEONLY;
if (printflags & PRINT_TYPESET) {
if ((p->node.flags & (PM_READONLY|PM_SPECIAL)) ==
@@ -5326,7 +5330,14 @@ printparamnode(HashNode hn, int printflags)
*/
return;
}
- printf("typeset ");
+ if (locallevel && p->level >= locallevel) {
+ printf("typeset "); /* printf("local "); */
+ } else if (p->node.flags & PM_EXPORTED) {
+ printf("export ");
+ } else if (locallevel) {
+ printf("typeset -g ");
+ } else
+ printf("typeset ");
}
/* Print the attributes of the parameter */
@@ -5339,7 +5350,9 @@ printparamnode(HashNode hn, int printflags)
if (pmptr->flags & PMTF_TEST_LEVEL) {
if (p->level)
doprint = 1;
- } else if (p->node.flags & pmptr->binflag)
+ } else if ((pmptr->binflag != PM_EXPORTED ||
+ ((p->node.flags & PM_LOCAL) || p->level)) &&
+ (p->node.flags & pmptr->binflag))
doprint = 1;
if (doprint) {
@@ -5351,9 +5364,8 @@ printparamnode(HashNode hn, int printflags)
}
putchar(pmptr->typeflag);
}
- } else {
+ } else
printf("%s ", pmptr->string);
- }
if ((pmptr->flags & PMTF_USE_BASE) && p->base) {
printf("%d ", p->base);
doneminus = 0;