On Wed, Sep 13, 2000 at 04:55:49PM -0700, Krzys Majewski wrote: > What's a good way to debug /bin/sh scripts? I thought there > was an interpreter option which would run the code line by > line, prompting after each line, but I looked through the > man/info pages and found nothing, or am I blind? I already > know about sh -x and sh -v, but these by themselves are still > a bit rough to use. If I get a good tip here I may never have > to write C code again ;) > -chris
sh -x is about all i have found for stepping through the script, i agree its rather rough, this is why i usually add debugging code to my script, generally just echoing various things such as variable values and telling me which way certain tests went. i do this like so: [ "$DEBUG" = 1 ] && echo 1>&2 "$PRG: DEBUG: foobar is $foo" then at the start of the script i have: DEBUG=0 when i need debug info i change it to: DEBUG=1 though my main scripts all accept the --debug switch which turns DEBUG=1. works pretty well for me. -- Ethan Benson http://www.alaska.net/~erbenson/
pgpwregw3kjxL.pgp
Description: PGP signature