Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: question about parameter expansion
- X-seq: zsh-users 20649
- From: Mikael Magnusson <mikachu@xxxxxxxxx>
- To: Zsh Users <zsh-users@xxxxxxx>
- Subject: Re: question about parameter expansion
- Date: Sat, 26 Sep 2015 20:33:57 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=YMspfD7GoFHwYxa4st3lsDLFkHW5XIK8JNfBbjtHPkE=; b=fYVDh7bpM67f2y/oi5EFC6boeQwBfkCr8tjNk8U4f304CAqR77ezprsyS47kDtPrbq RaWv4kHunAQnnxez4LrlKutdVe3+n/lGXM5E1cyHA1R6y1cuuVvALncuLRtWO/Ho2Rhn pMxWDozNNf+361mdQ3wDCy3iov40mDpkvbwqjnmJoV1PZCaEptKVlRPfX9y/5G01LtBc kJPMHkMaBmPEnQR6BW2vSSKa3EBAPPyKfvSf4hDm/3Z/J5rEbmzn4hNC1CBbXX3oBUH6 U+XobRhrMndjJCgSRHzLop0qIIJIFja7uXbEY02jFhl4EnjtRk2+uxcfM2/j2D7Jr3+R yt2Q==
- In-reply-to: <20150926180827.GA2617@gmail.com>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <20150926101839.GA14021@gmail.com> <CAHYJk3QegiGeqwiw834TVW+tFzvW5+HKV0cvopDyxOJnrZ6LYQ@mail.gmail.com> <20150926180827.GA2617@gmail.com>
On Sat, Sep 26, 2015 at 8:08 PM, Dmitri Vereshchagin
<dmitri.vereshchagin@xxxxxxxxx> wrote:
> * Mikael Magnusson <mikachu@xxxxxxxxx> [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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author