On Tue, Oct 30, 2007 at 06:58:10PM -0600, Eric Blake wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > According to Scott Moser on 10/30/2007 7:12 AM: > > #===== test.sh ===== > > x=$(cat <<"EOF" > > bad' syntax > > EOF > > ) > > > > > So, I'm not 100% certain what the "correct" behavior is, but it > > certainly seems like this should work. > > POSIX requires this to work when inside $(), but leaves it unspecified > when inside ``. Yes, all released versions of bash are buggy when it > comes to 100% compliance to the POSIX rules for $() parsing (and more > annoyingly, with different bugs as you move from 3.1 to 3.2). [...]
Note that it's the same as for $( case a in a) ... esac ) It fails in every shell but ash and ksh93. I thought the POSIX case a in (a) ... esac was introduced partly because of that, but I may be wrong as I can find no trace of it in the spec. Anyway, that was just to say that the bug being discussed here is also in the other shells: pdksh and its derivatives (posh, mksh), ksh88 (so most commercial POSIX sh) and zsh. And all so called POSIX shells are buggy when it comes to 100% compliance. I find that bash is probably one of (if not the) most compliant (that's the one thing I use bash for). At least when a non-compliance is spotted, it's fixed in the next release. Compare to ksh88 based sh on commercial Unices that still have the same bugs 10 years after. Please name one sh that is 100% POSIX compliant (and then please specify what you mean by 100% POSIX compliant :)). -- Stéphane