diff --git a/src/cmd/ksh93/sh/macro.c b/src/cmd/ksh93/sh/macro.c index 82dfeed13..9ab89b104 100644 --- a/src/cmd/ksh93/sh/macro.c +++ b/src/cmd/ksh93/sh/macro.c @@ -2118,7 +2118,7 @@ static void comsubst(Mac_t *mp,register Shnode_t* t, int type) } sfputc(stkp,c); } - sfputc(stkp,' '); /* rhbz#982142: a=`some_alias` leaked memory, a=`some_alias ` did not! TODO: non-hack fix */ + sfputc(stkp,'\n'); /* a=`some_alias` leaked memory, a=`some_alias` did not! TODO: non-hack fix */ c = stktell(stkp); str=stkfreeze(stkp,1); /* disable verbose and don't save in history file */ diff --git a/src/cmd/ksh93/tests/subshell.sh b/src/cmd/ksh93/tests/subshell.sh index 1f941e42a..450f44fa7 100755 --- a/src/cmd/ksh93/tests/subshell.sh +++ b/src/cmd/ksh93/tests/subshell.sh @@ -950,5 +950,15 @@ v=main (v=sub; (d=${ v=shared; }; [[ $v == shared ]]) ) || err_exit "shared comsub in nested subshell wrongly scoped (2)" [[ $v == main ]] || err_exit "shared comsub leaks out of subshell (7)" +# ====== +# After the memory leak patch for rhbz#982142, this minor regression was introduced: +# if a backtick command substitution expanded an alias, an extra space was inserted. +exp='word' +alias a='print -n wo\' +got=$(eval 'echo "`a`rd"') +unalias a +[[ $got == "$exp" ]] || err_exit 'backtick comsub with alias:' \ + "expected $(printf %q "$exp"), got $(printf %q "$got")" + # ====== exit $((Errors<125?Errors:125))