[patch] avoid some pitt falls using simple error handling

walter harms wharms at bfs.de
Sat Apr 18 17:27:24 UTC 2009



Cristian Ionescu-Idbohrn schrieb:
> 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##*/}.
> 
> 

yep, but i allway forget what these ## %% mean :)

re,
 wh


More information about the busybox mailing list