mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-01-01 05:16:05 +01:00
47704: POSIX export and readonly ignore "-p" when parameter names also appear
This commit is contained in:
parent
82ff9f24f1
commit
71b747567e
4 changed files with 17 additions and 7 deletions
|
@ -1,5 +1,9 @@
|
|||
2021-04-18 Bart Schaefer <schaefer@zsh.org>
|
||||
|
||||
* 47704: Src/builtin.c, Src/params.c, Test/B02typeset.ztst:
|
||||
POSIX export and readonly ignore the "-p" option when parameter
|
||||
names are also present.
|
||||
|
||||
* 48560: Completion/compinit, Doc/Zsh/builtins.yo,
|
||||
Doc/Zsh/options.yo, Doc/Zsh/params.yo, Src/builtin.c,
|
||||
Src/options.c, Src/params.c, Src/subst.c, Src/zsh.h,
|
||||
|
|
|
@ -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')) {
|
||||
|
|
|
@ -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 "); */
|
||||
|
|
|
@ -620,7 +620,7 @@
|
|||
print ${+pbro} >&2
|
||||
(typeset -g pbro=3)
|
||||
(pbro=4)
|
||||
readonly -p pbro >&2 # shows up as "readonly" although unset
|
||||
readonly -p >&2 # shows up as "readonly" although unset
|
||||
typeset -gr pbro # idempotent (no error)...
|
||||
print ${+pbro} >&2 # ...so still readonly...
|
||||
typeset -g +r pbro # ...can't turn it off
|
||||
|
@ -1050,23 +1050,21 @@
|
|||
|
||||
$ZTST_testdir/../Src/zsh --emulate sh -f -c '
|
||||
PATH=/bin; export PATH; readonly PATH
|
||||
export -p PATH
|
||||
export -p PATH # Should be a no-op, -p ignored
|
||||
typeset -p PATH
|
||||
readonly -p'
|
||||
0: readonly/export output for exported+readonly+special when started as sh
|
||||
>export PATH=/bin
|
||||
>export -r PATH=/bin
|
||||
>readonly PATH=/bin
|
||||
|
||||
function {
|
||||
emulate -L sh
|
||||
MANPATH=/bin; export MANPATH; readonly MANPATH
|
||||
export -p MANPATH
|
||||
export -p MANPATH # Should be a no-op, -p ignored
|
||||
typeset -p MANPATH
|
||||
readonly -p
|
||||
}
|
||||
0: readonly/export output for exported+readonly+tied+special after switching to sh emulation
|
||||
>export MANPATH=/bin
|
||||
>export -rT MANPATH manpath=( /bin )
|
||||
>readonly MANPATH=/bin
|
||||
|
||||
|
|
Loading…
Reference in a new issue