[patch] avoid some pitt falls using simple error handling

Cristian Ionescu-Idbohrn cristian.ionescu-idbohrn at axis.com
Sat Apr 18 13:01:02 UTC 2009


On Sat, 18 Apr 2009, walter harms wrote:

> you are right error handling is important
> may be can redefine croak() to
>
>
> error() {
>        echo "$tag: $*" >&2
>        exit 1
> }

Right.  See attached.

> additional points for having logger: (maybe this is to much but i am
> not sure)
>
> if [ -x /usr/bin/logger ]
> then
> 	ECHO=/usr/bin/logger -s -t $(basename $0)
> else
> 	ECHO=echo
> fi

Maybe.  But this is simplier:

ECHO=echo
! type logger >/dev/null 2>&1 || ECHO="logger -s -t$tag"

By the way, $(basename $0) is more expensive than ${0##*/}.


Cheers,

-- 
Cristian
-------------- next part --------------
A non-text attachment was scrubbed...
Name: simple.script.2.patch
Type: text/x-diff
Size: 2371 bytes
Desc: 
URL: <http://lists.busybox.net/pipermail/busybox/attachments/20090418/50664afb/attachment.bin>


More information about the busybox mailing list