diff --git a/NEWS b/NEWS index 4769e0f0e..46ec224cc 100644 --- a/NEWS +++ b/NEWS @@ -3,6 +3,12 @@ For full details, see the git log at: https://github.com/ksh93/ksh Any uppercase BUG_* names are modernish shell bug IDs. +2020-09-24: + +- An omission made it impossible to turn off brace expansion within command + substitutions (`...`, $(...) or ${ ...; }) as the code for parsing these + did not check the -B/braceexpand option. This check has now been added. + 2020-09-23: - Fixed a crash that could occur when running a pipeline containing diff --git a/src/cmd/ksh93/include/version.h b/src/cmd/ksh93/include/version.h index fea99fb82..1c08d8894 100644 --- a/src/cmd/ksh93/include/version.h +++ b/src/cmd/ksh93/include/version.h @@ -17,4 +17,4 @@ * David Korn * * * ***********************************************************************/ -#define SH_RELEASE "93u+m 2020-09-23" +#define SH_RELEASE "93u+m 2020-09-24" diff --git a/src/cmd/ksh93/sh/macro.c b/src/cmd/ksh93/sh/macro.c index 69319f1d5..3a8ef035d 100644 --- a/src/cmd/ksh93/sh/macro.c +++ b/src/cmd/ksh93/sh/macro.c @@ -2489,10 +2489,11 @@ static void endfield(register Mac_t *mp,int split) { mp->shp->argaddr = 0; #if SHOPT_BRACEPAT - count = path_generate(mp->shp,argp,mp->arghead); -#else - count = path_expand(mp->shp,argp->argval,mp->arghead); + if(sh_isoption(SH_BRACEEXPAND)) + count = path_generate(mp->shp,argp,mp->arghead); + else #endif /* SHOPT_BRACEPAT */ + count = path_expand(mp->shp,argp->argval,mp->arghead); if(count) mp->fields += count; else if(split) /* pattern is null string */ diff --git a/src/cmd/ksh93/tests/options.sh b/src/cmd/ksh93/tests/options.sh index f0399a47c..b0bc12879 100755 --- a/src/cmd/ksh93/tests/options.sh +++ b/src/cmd/ksh93/tests/options.sh @@ -547,5 +547,19 @@ print $'alias print=:\nprint foobar' > dotfile "$SHELL" -m -c '[[ -o monitor ]]' || err_exit 'option -m on command line does not work' "$SHELL" -o monitor -c '[[ -o monitor ]]' || err_exit 'option -o monitor on command line does not work' +# ====== +# Brace expansion could not be turned off in command substitutions (rhbz#1078698) +set -B +expect='test{1,2}' +actual=$(set +B; echo `echo test{1,2}`) +[[ $actual == "$expect" ]] || err_exit 'Brace expansion not turned off in `comsub`' \ + "(expected $(printf %q "$expect"), got $(printf %q "$actual"))" +actual=$(set +B; echo $(echo test{1,2})) +[[ $actual == "$expect" ]] || err_exit 'Brace expansion not turned off in $(comsub)' \ + "(expected $(printf %q "$expect"), got $(printf %q "$actual"))" +actual=$(set +B; echo ${ echo test{1,2}; }) +[[ $actual == "$expect" ]] || err_exit 'Brace expansion not turned off in ${ comsub; }' \ + "(expected $(printf %q "$expect"), got $(printf %q "$actual"))" + # ====== exit $((Errors<125?Errors:125))