On Thu, 16 Sep 2004, Alfred M. Szmidt wrote:
>Could someone explain the following behaviour for me? Because I sure
>do not understand it.
>
>address@hidden:/tmp/foo$ touch 1 2 3 4 5
>address@hidden:/tmp/foo$ foo=`ls`
Here, ls knows it is not outputting to a terminal, so implies the "-1"
option.
>address@hidden:/tmp/foo$ /bin/echo $foo
>1 2 3 4 5
Here the shell splits up the arguments and /bin/echo sees argc==5 (or it
it 6 to include argv[0]?).
>address@hidden:/tmp/foo$ /bin/echo "$foo"
>1
>2
>3
>4
>5
Here the shell passes the single argument and /bin/echo sees argc==1.
>address@hidden:/tmp/foo$ foo='1 2 3 4 5'
>address@hidden:/tmp/foo$ /bin/echo $foo
>1 2 3 4 5
>address@hidden:/tmp/foo$ /bin/echo "$foo"
>1 2 3 4 5
These shouldn't cause any surprises, I hope.
Cheers,
Phil