[CentOS] Scripting question

Wed May 9 20:37:42 UTC 2007
Garrick Staples <garrick at usc.edu>

On Wed, May 09, 2007 at 03:28:53PM -0500, Frank M. Ramaekers alleged:
> >The first line in your function is only logging its first argument, not
> >all arguments; and since you pass $line unquoted, the first word is the
> >first argument.
> >
> >You could either quote $line: ``LogIt "$line"'', or use all arguments
> in
> >LogIt: ``Msg="$@"''.
> >
> >-- 
> >Garrick Staples, GNU/Linux HPCC SysAdmin
> >University of Southern California
> >
> >09 F9 11 02 9D 74 E3 5B D8 41 56 C5 63 56 88 C0
> 
> That makes sense now...I didn't realize the difference...thanks!

So now that that makes sense to you, let me say that you should use both
solutions :)

Quoting $line ensures that special meta-characters aren't expanded.  For
example, if $line contained a *, then the shell could expand it with
files in the current directory.

And using $@ instead of $1 in LogIt is just more flexible and is closer
to your actual intention of "log everything I pass on this line."

-- 
Garrick Staples, GNU/Linux HPCC SysAdmin
University of Southern California

09 F9 11 02 9D 74 E3 5B D8 41 56 C5 63 56 88 C0
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.centos.org/pipermail/centos/attachments/20070509/70eb8bf5/attachment-0004.sig>