1
0
Fork 0
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:
Martijn Dekker 2022-02-05 15:04:12 +00:00
parent a8dd1bbd9d
commit 493a31053e
6 changed files with 28 additions and 4 deletions

View file

@ -728,6 +728,13 @@ exp='typeset -x bar=2'
got=$(typeset -p bar)
[[ $got == "$exp" ]] || err_exit 'Variable ${bar} should be exported' \
"(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
# ======