diff --git a/NEWS b/NEWS index 36bf81561..9745404a7 100644 --- a/NEWS +++ b/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. +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: - Fixed a bug in 'typeset -p': for an indexed array variable that is set diff --git a/src/cmd/ksh93/data/builtins.c b/src/cmd/ksh93/data/builtins.c index 446d8adef..007d19951 100644 --- a/src/cmd/ksh93/data/builtins.c +++ b/src/cmd/ksh93/data/builtins.c @@ -169,7 +169,7 @@ const struct shtable3 shtab_builtins[] = const char sh_set[] = "[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 " "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 " diff --git a/src/cmd/ksh93/include/version.h b/src/cmd/ksh93/include/version.h index 4fb00d8dd..9d4263dc2 100644 --- a/src/cmd/ksh93/include/version.h +++ b/src/cmd/ksh93/include/version.h @@ -21,7 +21,7 @@ #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_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 /* Scripts sometimes field-split ${.sh.version}, so don't change amount of whitespace. */ diff --git a/src/cmd/ksh93/sh.1 b/src/cmd/ksh93/sh.1 index 7e927a5ef..f408c88d4 100644 --- a/src/cmd/ksh93/sh.1 +++ b/src/cmd/ksh93/sh.1 @@ -7388,7 +7388,12 @@ See \f2History Expansion\fP above. .TP 8 .B \-a 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 .B \-b Prints job completion messages as soon as a background job changes diff --git a/src/cmd/ksh93/sh/name.c b/src/cmd/ksh93/sh/name.c index 0cbb80721..521e36569 100644 --- a/src/cmd/ksh93/sh/name.c +++ b/src/cmd/ksh93/sh/name.c @@ -2197,10 +2197,15 @@ static void attstore(register Namval_t *np, void *data) 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) { register char *value; register struct adata *ap = (struct adata*)data; + if(strchr(np->nvname,'.')) + return; ap->tp = 0; if(nv_isattr(np,NV_IMPORT) && 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. */ - char **sh_envgen(void) { register char **er; diff --git a/src/cmd/ksh93/tests/attributes.sh b/src/cmd/ksh93/tests/attributes.sh index 3d2911350..dba147091 100755 --- a/src/cmd/ksh93/tests/attributes.sh +++ b/src/cmd/ksh93/tests/attributes.sh @@ -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 # ======