zsh-users
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Zsh Users <zsh-users@zsh.org>
Subject: Re: brace expansion in array subscript
Date: Sun, 27 Jul 2014 17:39:04 -0700	[thread overview]
Message-ID: <140727173904.ZM18201@torch.brasslantern.com> (raw)
In-Reply-To: <alpine.DEB.2.02.1407271325560.9969@MyComp.rgm-web.net>

On Jul 27,  2:57pm, Rory Mulvaney wrote:
}
} echo ${arr[{2,5}]}
} 
} Why doesn't that get expanded into "echo ${arr[2]} ${arr[5]}"?

Array subscripts are already a comma-separated pair of arithmetic
expressions (or a quoted string value for associative arrays), and
curly braces already have their own special meaning in parameter
expansion expressions.  The syntax for brace expansion doesn't fit
well here.

} It seems there would be lots of convenient uses of this feature.

If you really need it, you can get it this way:

    echo ${(e):-\${arr[{2,5}]}}


      reply	other threads:[~2014-07-28  0:39 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-27 19:57 Rory Mulvaney
2014-07-28  0:39 ` Bart Schaefer [this message]

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=140727173904.ZM18201@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=zsh-users@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).