mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
Do not export variables with dot names (re: 8e72608c
)
Variables with a dot in their name, such as those declared in namespace { ... } blocks, are usually stored in a separate tree with their actual names not containing any dots. But under some circumstances, including at least direct assignment of a non-preexisting dot variable, dot variables are stored in the main sh.var_tree with names actually containing dots. With allexport active, those could end up exported to the environment. This bug was also present in previous release versions of ksh. src/cmd/ksh93/sh/name.c: pushnam(): - Check for a dot in the name before pushing a variable to export.
This commit is contained in:
parent
a8dd1bbd9d
commit
493a31053e
6 changed files with 28 additions and 4 deletions
8
NEWS
8
NEWS
|
@ -3,6 +3,14 @@ For full details, see the git log at: https://github.com/ksh93/ksh/tree/1.0
|
||||||
|
|
||||||
Any uppercase BUG_* names are modernish shell bug IDs.
|
Any uppercase BUG_* names are modernish shell bug IDs.
|
||||||
|
|
||||||
|
2022-02-05:
|
||||||
|
|
||||||
|
- Fixed: the -a/--allexport shell option incorrectly exported some variables
|
||||||
|
with names containing a dot to the environment. Note that the '-x' typeset
|
||||||
|
attribute may still be set for them, but this will now not have any
|
||||||
|
effect. Variables created in namespaces declared with the 'namespace'
|
||||||
|
keyword are only exported while their namespace is active.
|
||||||
|
|
||||||
2022-02-04:
|
2022-02-04:
|
||||||
|
|
||||||
- Fixed a bug in 'typeset -p': for an indexed array variable that is set
|
- Fixed a bug in 'typeset -p': for an indexed array variable that is set
|
||||||
|
|
|
@ -169,7 +169,7 @@ const struct shtable3 shtab_builtins[] =
|
||||||
|
|
||||||
const char sh_set[] =
|
const char sh_set[] =
|
||||||
"[a?All variables that are assigned a value while this option is on are "
|
"[a?All variables that are assigned a value while this option is on are "
|
||||||
"automatically exported.]"
|
"automatically exported, unless they have a dot in their name.]"
|
||||||
"[b?The shell writes a message to standard error as soon it detects that "
|
"[b?The shell writes a message to standard error as soon it detects that "
|
||||||
"a background job completes rather than waiting until the next prompt.]"
|
"a background job completes rather than waiting until the next prompt.]"
|
||||||
"[e?A simple command that has an non-zero exit status will cause the shell "
|
"[e?A simple command that has an non-zero exit status will cause the shell "
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
|
|
||||||
#define SH_RELEASE_FORK "93u+m" /* only change if you develop a new ksh93 fork */
|
#define SH_RELEASE_FORK "93u+m" /* only change if you develop a new ksh93 fork */
|
||||||
#define SH_RELEASE_SVER "1.0.0-beta.2" /* semantic version number: https://semver.org */
|
#define SH_RELEASE_SVER "1.0.0-beta.2" /* semantic version number: https://semver.org */
|
||||||
#define SH_RELEASE_DATE "2022-02-04" /* must be in this format for $((.sh.version)) */
|
#define SH_RELEASE_DATE "2022-02-05" /* must be in this format for $((.sh.version)) */
|
||||||
#define SH_RELEASE_CPYR "(c) 2020-2022 Contributors to ksh " SH_RELEASE_FORK
|
#define SH_RELEASE_CPYR "(c) 2020-2022 Contributors to ksh " SH_RELEASE_FORK
|
||||||
|
|
||||||
/* Scripts sometimes field-split ${.sh.version}, so don't change amount of whitespace. */
|
/* Scripts sometimes field-split ${.sh.version}, so don't change amount of whitespace. */
|
||||||
|
|
|
@ -7388,7 +7388,12 @@ See \f2History Expansion\fP above.
|
||||||
.TP 8
|
.TP 8
|
||||||
.B \-a
|
.B \-a
|
||||||
All variables that are assigned a value while this option is on
|
All variables that are assigned a value while this option is on
|
||||||
are automatically exported.
|
are automatically exported, unless they have a dot in their name.
|
||||||
|
Variables created in namespaces declared with the
|
||||||
|
.B namespace
|
||||||
|
keyword (see
|
||||||
|
.I Name Spaces
|
||||||
|
above) are only exported while their name space is active.
|
||||||
.TP 8
|
.TP 8
|
||||||
.B \-b
|
.B \-b
|
||||||
Prints job completion messages as soon as a background job changes
|
Prints job completion messages as soon as a background job changes
|
||||||
|
|
|
@ -2197,10 +2197,15 @@ static void attstore(register Namval_t *np, void *data)
|
||||||
ap->attval = strcopy(++ap->attval,nv_name(np));
|
ap->attval = strcopy(++ap->attval,nv_name(np));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Called from sh_envgen() to push an individual variable to export
|
||||||
|
*/
|
||||||
static void pushnam(Namval_t *np, void *data)
|
static void pushnam(Namval_t *np, void *data)
|
||||||
{
|
{
|
||||||
register char *value;
|
register char *value;
|
||||||
register struct adata *ap = (struct adata*)data;
|
register struct adata *ap = (struct adata*)data;
|
||||||
|
if(strchr(np->nvname,'.'))
|
||||||
|
return;
|
||||||
ap->tp = 0;
|
ap->tp = 0;
|
||||||
if(nv_isattr(np,NV_IMPORT) && np->nvenv)
|
if(nv_isattr(np,NV_IMPORT) && np->nvenv)
|
||||||
*ap->argnam++ = np->nvenv;
|
*ap->argnam++ = np->nvenv;
|
||||||
|
@ -2213,7 +2218,6 @@ static void pushnam(Namval_t *np, void *data)
|
||||||
/*
|
/*
|
||||||
* Generate the environment list for the child.
|
* Generate the environment list for the child.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
char **sh_envgen(void)
|
char **sh_envgen(void)
|
||||||
{
|
{
|
||||||
register char **er;
|
register char **er;
|
||||||
|
|
|
@ -728,6 +728,13 @@ exp='typeset -x bar=2'
|
||||||
got=$(typeset -p bar)
|
got=$(typeset -p bar)
|
||||||
[[ $got == "$exp" ]] || err_exit 'Variable ${bar} should be exported' \
|
[[ $got == "$exp" ]] || err_exit 'Variable ${bar} should be exported' \
|
||||||
"(expected $(printf %q "$exp"), got $(printf %q "$got"))"
|
"(expected $(printf %q "$exp"), got $(printf %q "$got"))"
|
||||||
|
.foo=
|
||||||
|
.foo.bar=baz
|
||||||
|
exp=''
|
||||||
|
got=$(env | grep '^\.foo[.=]')
|
||||||
|
[[ $got == "$exp" ]] || err_exit 'Variables with dots in name exported' \
|
||||||
|
"(expected $(printf %q "$exp"), got $(printf %q "$got"))"
|
||||||
|
unset .foo.bar .foo
|
||||||
set +o allexport
|
set +o allexport
|
||||||
|
|
||||||
# ======
|
# ======
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue