[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Expansion of unquoted special parameter $@ when used as the word for
From: |
Chet Ramey |
Subject: |
Re: Expansion of unquoted special parameter $@ when used as the word for a HERE STRING |
Date: |
Wed, 6 Nov 2019 16:14:39 -0500 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:68.0) Gecko/20100101 Thunderbird/68.2.1 |
On 11/5/19 5:15 PM, Robin A. Meade wrote:
OK, thanks. I'll avoid unquoted $* and $@ in my scripts.
However, I was testing the validity of this sentence:
"In contexts where word splitting is not performed, this expands to a
single word with each positional parameter separated by a space."
– https://www.gnu.org/software/bash/manual/bash.html#Special-Parameters
That statement appears to be true for variable assignments:
set -- a 'b c'
v=$@
# ^ word splitting does not occur in this context
echo "$v"
Prints:
a b c
But not for here strings:
cat <<< $@;
# ^ again a context in which word splitting does not occur
Prints:
a b c
Thanks for the report and discussion.
This is technically undefined, as explained in previous messages in this
thread, but I agree that it should be consistent between these two
contexts. I'll fix here-string expansion to make that work the same as
on the rhs of assignment statements.
Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU address@hidden http://tiswww.cwru.edu/~chet/