[plug] bash scripting

Brad Campbell brad at wasp.net.au
Tue Dec 23 19:08:22 WST 2003


G'day all,

I have some bash scripts I knocked up that do some stuff that could be 
irrecoverable if it went wrong.
To prevent this I have a

set -e

in the scripts which will abort on any error. Now this is all well and 
good, but bash takes any command that exits with an error code of > 0 to 
mean an error. Some examples would be

let count=0  ; Exits with error code of 1
OPIE=`ps | grep opie | grep -v grep` ;  exits with an error code of 1 if 
the string is null.

I have kludged around it with such bodgery as

let count=0 || true

as the shell does not look at the error code if it thinks it might be 
part of a boolean expression.

Is there a better way?

Merry Christmas all,
Brad



More information about the plug mailing list