zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-workers@zsh.org
Subject: xtrace and array assignment
Date: Sat, 02 Mar 2013 08:36:47 -0800	[thread overview]
Message-ID: <130302083647.ZM11704@torch.brasslantern.com> (raw)

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.


             reply	other threads:[~2013-03-02 16:37 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-02 16:36 Bart Schaefer [this message]
2013-03-05 19:29 ` Peter Stephenson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=130302083647.ZM11704@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).