Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: A minor syntax question
- X-seq: zsh-users 21625
- From: Jesper Nygårds <jesper.nygards@xxxxxxxxx>
- To: Zsh Users <zsh-users@xxxxxxx>
- Subject: Re: A minor syntax question
- Date: Tue, 7 Jun 2016 20:47:28 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=BYGNLMT/tqbFfzETCFdeUkI+FTiAratCW0K2Ie1ovf0=; b=cquBVfTQMlvwwtzM3QUYg5G071eOG2WG43qsYVTboxWrKiQKiBEH7++LAt7EZlOz6x c/TaRPYD/S5cbjpEB8jNodhWJ8R1thD2I3vDswd14b3IriIhtBEKvT7nxITJsgkl0YwQ PtWwLff+pBrcyYhFX/lougrzSHuffPD55GJxktBuF6fiHu2gPqdeXP5lVANuakXFCdE6 QYCYdhSBRl29Q6Ub49++VhO/auSyONcNZJUUp8I7wT9CtIEVEQm1UxX5Y8FutiDAy+Yd a5cZiNFffEcXlgo0GXJ+OMzN5N9Twf+WgF19Q9q71YJAOFmJsHq+wALPi2TcouLBOeLP 8WLg==
- In-reply-to: <26949.1465300483@thecus.kiddle.eu>
- 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: <CABZhJg8eEekK6hdrGY-2uTB9V6LF5JqkHPOpT6NXx=Gkeeb1HQ@mail.gmail.com> <26949.1465300483@thecus.kiddle.eu>
Both your examples work great, Oliver. Thank you.
Inspired by your second example I also found a solution which more closely
follows the way I have been thinking about the problem, and that I find
quite readable:
typearg="("${(j: -o :)${types:#-t}/#/-type }")"
On Tue, Jun 7, 2016 at 1:54 PM, Oliver Kiddle <okiddle@xxxxxxxxxxx> wrote:
> Jesper Nygårds wrote:
> > typearg="("${"$(print -- '-o -type '${^types:#-t})"#-o }")"
>
> > away the leading '-o'. It works as intended, but I feel it is more
> > complicated than required. In particular, I couldn't find a way to make
> the
> > '${^...}' parameter expansion trigger without the embedded print
> statement.
>
> Joining the array to form a string should avoid the need for a print,
> allowing the #-o to apply to the string as a whole. E.g:
>
> typearg=${${(j. .):-'-o -type '${^types:#-t}}#-o }
>
> Shorter versions should be possible such as the following:
>
> typearg="${${=types//-t/-o -type}[2,-1]}"
>
> I'd be inclined to keep typearg as an array, however.
>
> Oliver
>
Messages sorted by:
Reverse Date,
Date,
Thread,
Author