Re: Debugguing shel scripts

Christopher Lee <[email protected]>
Newsgroups gmane.org.user-groups.linux.dunedin.general
Message-ID <CACM68miirFCkXzQdokjmPzqkbQ2X9pgUdp9wf9=hhxJ53Epang@mail.gmail.com>
Hi Worik,

I'm not sure about a debugger but I've found putting `set -x` at the top of
my scripts helps me with debugging.
This will print to screen what each line of the script is doing, for
example:

The script:
#!/bin/bash

set -x

false
blah=This is something: $(uptime)
echo $blah

results in:
$ ./test_script.sh
+ false
++ uptime
+ blah='This is something:  11:16:17 up  1:53,  4 users,  load average:
0.39, 0.30, 0.33'
+ echo This is something: 11:16:17 up 1:53, 4 users, load average: 0.39,
0.30, 0.33
This is something: 11:16:17 up 1:53, 4 users, load average: 0.39, 0.30, 0.33


Hope this may be of some help,
Chris


On Fri, Jul 5, 2013 at 10:56 AM, Worik Stanton <[email protected]>wrote:

> I have a misbehaving shell script.
>
> Are there any debuggers I can use that will let me step through a shell
> script?
>
> cheers
> W
> --
> "As I went walking I saw a sign there And on the sign it said 'No
> Trespassing' But on the other side it didn't say nothing, That side
> was made for you and me" – Woody
>        [email protected] 021-1680650, (03) 4821804
>
>
> _______________________________________________
> DunLUG mailing list
> [email protected]
> http://lists.ethernal.org/listinfo/dunlug
> DunLUG Wiki - http://dunlug.kallisti.net.nz/
>

_______________________________________________
DunLUG mailing list
[email protected]
http://lists.ethernal.org/listinfo/dunlug
DunLUG Wiki - http://dunlug.kallisti.net.nz/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.