[plug] Bash "Processing" Script

Bernd Felsche bernie at innovative.iinet.net.au
Fri Jun 11 15:23:45 WST 2004


On Fri, Jun 11, 2004 at 02:28:26PM +0800, Jay Turner wrote:
> James said:
> > However, there is a fundamental error in using "[ true ]".
> > Remember, `[` is just a programme that basically expects a bunch
> > of parameters and returns a result of 0 or 1. In the case of "[
> > true ]", the `[` programme is actually evaluating whether the
> > literal text "true" has non-zero length -- that has nothing to
> > do with the `true` command! Try "[ false ]" -- it will 'succeed'
> > forever!

> So I would actually need to use
> while true
> do
> 
> or as you showed
> while true; do
> The man page for bash, I find, is just too hard to read. So I go
> with tutorials on the net.
> Most of them don't cover advanced things like this... that's where
> you guys come in :-)

If there are nine ways to skin a cat, there are nine million ways of
solving a problem in software.

What is "best" is what solves the problem in a manner that you can
manage. As your expertise grows, you  will find new "best"
solutions.

> I think I understand it all now pretty much. Is there a way that
> we can tell the 'while' that "it" is now false.

> Or is killing the 'while' process the only option (for this
> scenario anyway)? (I assume that if there was, Bernd would have
> suggested it in the first place..)

"Killing" is not the only option; just the easiest way of signalling
a termination. If the dd were just of normal files, then one could
compare sizes and terminate if they match. That doesn't work for
special files and the extra coding effort is seldom worth it. Nor is
the risk of introducing bugs or of leaving "crap" lying around by
creating "semaphore files" and the like.

I have enough trouble explaining my "normal" shell programs. Trying
to explain co-routines, etc is beyond my patience to explain. I'll
post a list of shell programming references you may find useful.

There's a disturbing tendency for technical books to have between
500 and 800 pages of bulk; but my favourite ones are about half that
size. It's much harder to write a short book and a mega-tome.

-- 
/"\ Bernd Felsche - Innovative Reckoning, Perth, Western Australia
\ /  ASCII ribbon campaign | I'm a .signature virus!
 X   against HTML mail     | Copy me into your ~/.signature
/ \  and postings          | to help me spread!



More information about the plug mailing list