zsh-workers
 help / color / mirror / code / Atom feed
* xtrace and array assignment
@ 2013-03-02 16:36 Bart Schaefer
  2013-03-05 19:29 ` Peter Stephenson
  0 siblings, 1 reply; 2+ messages in thread
From: Bart Schaefer @ 2013-03-02 16:36 UTC (permalink / raw)
  To: zsh-workers

The trace output for assignment to array elements does not expand the
index value (the string inside the square brackets):

schaefer<512> {
cursh> typeset -A traceme
cursh> theindex=somestring
cursh> set -x
cursh> traceme[$theindex]=$theindex
cursh> set +x
cursh> }
: zsh:19:cursh; traceme[$theindex]=somestring 
: zsh:20:cursh; set +x
schaefer<513> 

I'm a little conflicted about this one because (a) the above behavior
matches bash and (b) sometimes seeing it unexpanded is what you want.
On the other hand, if I'm tracing a function with "typeset -ft" and
the assignment looks like thearray[$2]=thevalue, it'd be helpful to see
what $2 is, because the trace does not include the function call itself
from the surrounding context.

Yes, that specific example can be worked around by adding something such
as ": $@" to the top of the function, but there may be other contexts
where it's difficult follow where a reference came from, and the intent
of typeset -ft is to avoid having to change the function.

It's also always irked me a little that the verbose option doesn't print
anything for assignments, so maybe combining verbose and xtrace could
have some meaning here.  However, I haven't really dug in to how xtrace
for assignments is implemented, so this might be rather difficult, and
of course we don't want to accidentally introduce side-effects.


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: xtrace and array assignment
  2013-03-02 16:36 xtrace and array assignment Bart Schaefer
@ 2013-03-05 19:29 ` Peter Stephenson
  0 siblings, 0 replies; 2+ messages in thread
From: Peter Stephenson @ 2013-03-05 19:29 UTC (permalink / raw)
  To: zsh-workers

On Sat, 02 Mar 2013 08:36:47 -0800
Bart Schaefer <schaefer@brasslantern.com> wrote:
> It's also always irked me a little that the verbose option doesn't print
> anything for assignments, so maybe combining verbose and xtrace could
> have some meaning here.  However, I haven't really dug in to how xtrace
> for assignments is implemented, so this might be rather difficult, and
> of course we don't want to accidentally introduce side-effects.

I'd quite like something a bit more sophisticated, say a number
determining the depth to which xtrace output is shown, with the current
output somewhere in the middle of the scale (so in addition to expanding
indexes you could go the other way and only show e.g. function calls and
block constructs).

But that's a lot of work.

-- 
Peter Stephenson <p.w.stephenson@ntlworld.com>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-03-05 19:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-02 16:36 xtrace and array assignment Bart Schaefer
2013-03-05 19:29 ` Peter Stephenson

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).