bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: weird echo behaviour...


From: Philip Rowlands
Subject: Re: weird echo behaviour...
Date: Thu, 16 Sep 2004 16:35:32 +0100 (BST)

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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]