[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: ${var:+"quo ted"} and similar, inside unquoted here-docs
From: |
Eric Blake |
Subject: |
Re: ${var:+"quo ted"} and similar, inside unquoted here-docs |
Date: |
Mon, 30 Aug 2010 08:57:16 -0600 |
User-agent: |
Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.8) Gecko/20100806 Fedora/3.1.2-1.fc13 Mnenhy/0.8.3 Thunderbird/3.1.2 |
[adding bug-bash]
On 08/29/2010 08:48 AM, Ralf Wildenhues wrote:
With Solaris 10 sh (and others):
cat<<EOF
${var-"quo ted"}
EOF
"quo ted"
Whereas with bash (and others):
quo ted
Ouch. New one to me. ksh, zsh, and dash do not echo the quotes, so I'm
thinking it may be a bash bug; hence the cc.
Eric, did you have this in your recent autoconf.texi additions already?
It can be a problem for all of the stuff that gets expanded into here
documents.
Now, for the good news - the bug is easy to work around, while still
using a here-doc. A here-doc is parsed in a different context (no word
splitting, no filename expansion) than normal, so /bin/sh does NOT have
the bug related to "bad parameter" messages if you omit the quotes.
All shells that I had access to reliably gave the same output for:
cat <<EOF
${var-quo ted}
EOF
quo ted
--
Eric Blake eblake@redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
- Re: ${var:+"quo ted"} and similar, inside unquoted here-docs,
Eric Blake <=