Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Debugging functions zsh
- X-seq: zsh-users 10680
- From: Phil Pennock <phil.pennock@xxxxxxxxxxx>
- To: sac <sac_urs@xxxxxxxxxxx>
- Subject: Re: Debugging functions zsh
- Date: Tue, 5 Sep 2006 14:01:16 +0200
- Cc: Zsh users list <zsh-users@xxxxxxxxxx>
- In-reply-to: <20060905100823.10860.qmail@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Mail-followup-to: sac <sac_urs@xxxxxxxxxxx>, Zsh users list <zsh-users@xxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <20060905100823.10860.qmail@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Sender: Phil Pennock <phil@xxxxxxxxxxxxx>
On 2006-09-05 at 03:08 -0700, sac wrote:
> When we want to debug a script, we use the -x flag,
> like `zsh -x script_name', and we get all the
> variables that are set etc.
> How do we debug a function, which is sourced from a
> script, other than putting print statements manually
> here and there.
% setopt xtrace
% my_func
% unsetopt xtrace
This debugs everything the shell does, including precmd() evaluation
and so on, thus there will be a little bit extra in the function.
Alternatively, you can mark the function as traced. The "typeset"
command won't blank the function when you call it like this:
% typeset -f -t my_func
This may be more useful if the function is being called from other
functions. However, the trace tagging needs to happen _after_ the
function is defined.
% typeset -f -t fred
% function fred { print "Foo: $*" }
% fred wibble
Foo: wibble
% typeset -f -t fred
% fred wibble
+fred:0> print 'Foo: wibble'
Foo: wibble
%
See zshoptions(1)/XTRACE and zshbuiltins(1)/typeset.
-Phil
Messages sorted by:
Reverse Date,
Date,
Thread,
Author