how to debug .sh type script
Matthew Seaman
m.seaman at infracaninophile.co.uk
Mon May 31 08:12:44 UTC 2010
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 31/05/2010 08:59:04, Aiza wrote:
> Is there way to single step through each line of code and see the real
> values of the variables?
Not 'single step' as such -- what you can do is run with '-x' which
prints each line as it is executed. That's either:
sh -x scriptname
or you can add it to the #! line in the script, or just stick 'set -x'
somewhere in the script body.
If you use the 'set -x' form, you can set it up to trace through just
the interesting parts of your code. (Somewhat counter intuitively 'set
- -x' or 'set -o xtrace' turns on trace mode; 'set +x' or 'set +o xtrace'
turns it off)
This doesn't give you a way of arbitrarily querying the value of any
variable, but you will be able to see all variable assignments as part
of the trace.
There's also a '-v' flag which adds displaying input read by the shell
as it executes.
Cheers,
Matthew
- --
Dr Matthew J Seaman MA, D.Phil. 7 Priory Courtyard
Flat 3
PGP: http://www.infracaninophile.co.uk/pgpkey Ramsgate
JID: matthew at infracaninophile.co.uk Kent, CT11 9PW
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.14 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAkwDb3EACgkQ8Mjk52CukIyoLwCfdTamyG/PnEgdbWEDlZwaW28B
HCwAn2WhU6/GCLzamityi3YiW79OcjS9
=7vBz
-----END PGP SIGNATURE-----
More information about the freebsd-questions
mailing list