[lug] Bletcherous pipe, FIXME!

Jeffrey Haemer jeffrey.haemer at gmail.com
Thu Apr 2 15:46:48 MDT 2009


> Use echo instead of printf.  Echo is generally a shell builtin.


FWIW, printf is a builtin, too, at least in bash and dash.  Also in csh/tcsh
on my Mac.  Doesn't look like it is in busybox's ash.  Though in busybox,
everything is sort of a built-in. :-)


> Even better, put the whole thing into a subshell with ( ) and redirect the
> output of it all at once.


Using {} instead of () offers that benefit without the cost or
environment-shift of a subshell.   (Zan knows it won't much matter in this
case -- it's a one-shot -- but I still think it's worth a mention for the
less-frequent shell programmer.)

Truth to tell, if it were my scriipt, I might dump the redirection --
instead, have it print to stdout, then append to /etc/hosts.allow when I
invoke it.

   scriptname >> /etc/hosts.allow.

I like printing to stdout because it makes things easier to debug.  Still, I
probably only care because my code often has bugs.

-- 
Jeffrey Haemer <jeffrey.haemer at gmail.com>
720-837-8908 [cell]
303-997-1219 [Google Voice]
http://seejeffrun.blogspot.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lug.boulder.co.us/pipermail/lug/attachments/20090402/49f05287/attachment.html>


More information about the LUG mailing list