zsh-users
 help / color / mirror / code / Atom feed
From: Mikael Magnusson <mikachu@gmail.com>
To: Zsh Users <zsh-users@zsh.org>
Subject: Re: question about parameter expansion
Date: Sat, 26 Sep 2015 20:33:57 +0200	[thread overview]
Message-ID: <CAHYJk3R6xhpwZ2fArTfsKqKRTVcJH7oO335nT-93ko9cnMUJxg@mail.gmail.com> (raw)
In-Reply-To: <20150926180827.GA2617@gmail.com>

On Sat, Sep 26, 2015 at 8:08 PM, Dmitri Vereshchagin
<dmitri.vereshchagin@gmail.com> wrote:
> * Mikael Magnusson <mikachu@gmail.com> [2015-09-26 16:37]:
>> You have to think outside the box for this one,
>> bar=${${${+foo}#1}//0/baz}
>
> I thought that there is more concise way like some sort of ${name+word}
> counterpart.  Thank you.

Here's another variant, which may or may not be considered more
concise (it happens to be the exact same number of characters, but
uses fewer things, and probably doesn't work under ksh_arrays, but
then, what does, commas abounds),

bar=${${:-baz}[1,$+foo-1]}

-- 
Mikael Magnusson


  reply	other threads:[~2015-09-26 18:33 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-26 10:18 Dmitri Vereshchagin
2015-09-26 13:37 ` Mikael Magnusson
2015-09-26 17:41   ` ZyX
2015-09-26 17:57     ` Mikael Magnusson
2015-09-26 18:08   ` Dmitri Vereshchagin
2015-09-26 18:33     ` Mikael Magnusson [this message]
2015-09-26 18:57       ` Dmitri Vereshchagin
2015-09-26 21:11         ` Ray Andrews
2015-09-26 21:34           ` Bart Schaefer
2015-09-26 22:02             ` Ray Andrews
2015-09-27 16:58               ` Bart Schaefer
2015-09-27 18:29                 ` Ray Andrews
2015-09-27 18:43                   ` ZyX
2015-10-02 14:10                 ` Simon Ruderich
2015-10-02 16:35                   ` Ray Andrews
2015-10-02 19:07                     ` Simon Ruderich
2015-10-02 19:50                       ` Ray Andrews
2015-10-02 20:03                         ` latest manual Ray Andrews
2015-10-02 20:23                           ` Ray Andrews
2015-10-02 20:53                             ` Bart Schaefer
2015-10-02 21:55                               ` Ray Andrews
2015-10-03 18:49                                 ` Bart Schaefer
2015-10-03 10:01                               ` Simon Ruderich
2015-10-02 20:58                             ` Andrew Janke

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=CAHYJk3R6xhpwZ2fArTfsKqKRTVcJH7oO335nT-93ko9cnMUJxg@mail.gmail.com \
    --to=mikachu@gmail.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).