On Mon, May 27, 2002 at 12:17:27PM +0930, Tom Cook wrote:
| On  0, Squirrel <[EMAIL PROTECTED]> wrote:
| > 
| [implied question]
| > 
| > What's the meaning of "echo $@"?
|
| So if a script just has 'echo $@' in it, then it is functionally
| equivalent to 'echo' (except doesn't have the command line options,
| obviously).

Not true -- the contents of $@ is expanded first, then sent to the
command.  If you want to be safe and ensure the the "data" isn't
accidentally interpreted as arguments you need 'echo -- $@'.  Test it
out and see (also compare the differences between using ash and bash) :

$ cat /tmp/echo.sh
#!/bin/sh
echo $@

$ /tmp/echo.sh -e 'bar\nfoo'
-e bar
foo

$ /tmp/echo.sh 'bar\nfoo'
bar
foo

$ cat /tmp/echo.sh
#!/bin/bash
echo $@

$ /tmp/echo.sh 'bar\nfoo'
bar\nfoo

$ /tmp/echo.sh -e 'bar\nfoo'
bar
foo

$


-D

-- 

(E)ventually (M)allocs (A)ll (C)omputer (S)torage
 
GnuPG key : http://dman.ddts.net/~dman/public_key.gpg

Attachment: pgpfB1a5lAtKv.pgp
Description: PGP signature

Reply via email to