$ bash test.sh
test.sh: line 2: unexpected EOF while looking for matching `''
test.sh: line 6: syntax error: unexpected end of file
Above, bash errors on the single ' in "bad'".
The above syntax works in on my version of dash (0.5.3-5ubuntu2) and the
version of busybox ash that I tested (1.1.3).
Using the backtick operator works on my version of bash, and a version
2.05b.0 that I tested. backtick does not work on 3.1.17 (sles 10)
I actually see the same behavior as this version of bash on ksh from AIX
5.3.0.0. There, ksh works with `` bug fails with $().
So, I'm not 100% certain what the "correct" behavior is, but it
certainly seems like this should work.
Repeat-By:
printf "%s\n%s\n%s\n%s\n" \
'x=$(cat <<"EOF"' "bad' syntax" 'EOF' ')' > test.sh
bash test.sh
printf "%s\n%s\n%s\n%s\n" \
'x=`cat <<"EOF"' "bad' syntax" 'EOF' '`' > test.sh