From 7f2c81103b4c0eb27084ad33ec7a68e10df898cc Mon Sep 17 00:00:00 2001 From: Martijn Dekker Date: Mon, 15 Jun 2020 12:32:57 +0200 Subject: [PATCH] regress: avoid backporting a cmd subst bug from beta ksh 93v- beta introduced a regression with nested command substitutions: backticks nested in $( ) result in misdirected output. This has never been in 93u+, but since we're often backporting things, let's avoid backporting this bug. It is also useful if this shows up when running our bin/shtests against the actual beta by adding a SHELL=... argument. Ref.: https://github.com/att/ast/issues/478 src/cmd/ksh93/tests/subshell.sh: - Add reproducer submitted by the reporter as a regression test. --- src/cmd/ksh93/tests/subshell.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/cmd/ksh93/tests/subshell.sh b/src/cmd/ksh93/tests/subshell.sh index 9098e91c3..e7969f052 100755 --- a/src/cmd/ksh93/tests/subshell.sh +++ b/src/cmd/ksh93/tests/subshell.sh @@ -336,6 +336,17 @@ do for ((TEST=1; TEST<=${#testcase[@]}; TEST++)) shift 2 done +# Regression introduced in 93v- beta; let's make sure not to backport it to 93u+m +# Ref.: https://github.com/att/ast/issues/478 +expected='foo=bar' +actual=$( + foo=$(print `/bin/echo bar`) # should print nothing + print foo=$foo # should print "foo=bar" +) +[[ $actual == "$expected" ]] \ +|| err_exit 'Backticks nested in $( ) result in misdirected output' \ + "(expected $(printf %q "$expect"), got $(printf $q "$actual"))" + # the next tests loop on all combinations of # { SUB CAT INS TST APP } X { file-sizes } # where the file size starts at 1Ki and doubles up to and including 1Mi