Date: Mon, 31 May 2010 09:12:33 +0100 From: Matthew Seaman <m.seaman@infracaninophile.co.uk> To: Aiza <aiza21@comclark.com> Cc: "questions@freebsd.org" <questions@freebsd.org> Subject: Re: how to debug .sh type script Message-ID: <4C036F71.2080001@infracaninophile.co.uk> In-Reply-To: <4C036C48.3000307@comclark.com> References: <4C036C48.3000307@comclark.com>
next in thread | previous in thread | raw e-mail | index | archive | help
-----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@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-----
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4C036F71.2080001>