[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox
Subject:    writing robust scripts.
From:       "David Collier" <from_busybox_maillist () dexdyne ! com>
Date:       2010-11-30 22:08:00
Message-ID: memo.20101130220808.1860M () postmaster+dexdyne ! com ! cix ! co ! uk
[Download RAW message or body]

I am trying to make all the scripts on my system run under set -e; set -u.

Firstly I'd like them to be as robust as possible when deployed, and
secondly if one fails in the field after 15 months, I want an entry in my
system log file to give me a clue what happened.

It's darned hard work because all sorts of scripts return values to
indicate their success.... and -e wants everything non-zero to mean
"error"

[ It would be really useful if one could say set -e 100 - so that values
over 100 could be used as pass-back tokens, reserving 0 and 1 for
conventional OK/error ]

also loads of scripts exploit the fact that an undefined variable is
equivalent to a blank.

I've set up a trap on exit, and all "expected" exits go through a do_exit
macro... so I can log any script that fails.

What would be truly useful would be a way to pick up the line number in
which an error is detected. The best I can do at the moment is "error in
script 'fred'"

Comments welcome, but my question is - does anyone else actually try to
do this stuff, or does everyone just busk it ?

D
_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic