Angel Tsankov wrote:
> Eric Blake wrote:
>> According to Angel Tsankov on 2/15/2009 3:02 PM:
>>> I tried CPATH="${CPATH}${CPATH:+:}"~usr1/blah/blah. (I quote
>>> expansions just to be on the safe side, though I think home
>>> directories may not contain spaces.)
>> There are some contexts, such as variable assignments, where double
>> quotes are not necessary.
>>
>> foo='a b'
>> bar=$foo
>>
>> is just as safe as
>>
>> bar="$foo"
>>
>> In fact, it is MORE portable to avoid double quotes in assignments,
>> if you are worried about writing scripts portable to more than just
>> bash. Of these two constructs:
>>
>> foo="`echo "a b"`"
>> bar=`echo "a b"`
>>
>> only the setting of bar is guaranteed to parse correctly in all
>> shells.
> Eric, thanks for youy replay. If double quotes are not that portable, then
> how am I suppose to assign the output from some command to a variable when
> the output contains a space?
Word splitting doesn't happen on assignments, so:
$ var=$(echo "foo bar baz")
$ echo "$var"
foo bar baz
--
D.