Re: Debugging /bin/sh scripts?
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 12 $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
Re: Debugging /bin/sh scripts?
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 Put the line: set -x or call bash with the -x option to step through the script. -- Daniel E. Wilson [EMAIL PROTECTED]
Re: Debugging /bin/sh scripts?
line executed. -chris Date: 14 Sep 2000 09:46:49 -0700 In-Reply-To: Daniel E. Wilson's message of Thu, 14 Sep 2000 01:34:24 -0700 Message-ID: [EMAIL PROTECTED] Lines: 4 User-Agent: Gnus/5.0803 (Gnus v5.8.3) Emacs/20.5 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii --text follows this line-- Daniel E. Wilson [EMAIL PROTECTED] writes: Put the line: set -x or call bash with the -x option to step through the script.
Re: Debugging /bin/sh scripts?
I did find another thing, trap _foo DEBUG, where _foo is some function (or command) of your choosing. Do an info bash s debug -chris Ethan Benson [EMAIL PROTECTED] writes: 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 12 $PRG: DEBUG: foobar is $foo
Debugging /bin/sh scripts?
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
Re: Debugging /bin/sh scripts?
try using set -x in your script file, ie: #!/bin/bash set -x 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 -- Unsubscribe? mail -s unsubscribe [EMAIL PROTECTED] /dev/null -- As a general rule, if you have trouble with the binary system, then probably it is because you do not really understand the decimal system ... R.W. Hamming
Re: Debugging /bin/sh scripts?
'sh -n' will syntax-check a script without actually executing any of the commands. 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 -- -- | THKS : | Federated Insurance | | Jeff Howie | Information Systems - PC | | Int Programmer/Analyst | 204.786.6431.x.217| --