Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: question about parameter expansion



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