zsh-users
 help / color / mirror / code / Atom feed
From: "Jesper Nygårds" <jesper.nygards@gmail.com>
To: Zsh Users <zsh-users@zsh.org>
Subject: Re: A minor syntax question
Date: Tue, 7 Jun 2016 20:47:28 +0200	[thread overview]
Message-ID: <CABZhJg_2smdBcCcDa86fBB1Xw1DWCxpWBcCNwcxoCeMM7an9gQ@mail.gmail.com> (raw)
In-Reply-To: <26949.1465300483@thecus.kiddle.eu>

[-- Attachment #1: Type: text/plain, Size: 1070 bytes --]

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@yahoo.co.uk> 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
>

      reply	other threads:[~2016-06-07 18:47 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-07  6:58 Jesper Nygårds
2016-06-07 11:54 ` Oliver Kiddle
2016-06-07 18:47   ` Jesper Nygårds [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=CABZhJg_2smdBcCcDa86fBB1Xw1DWCxpWBcCNwcxoCeMM7an9gQ@mail.gmail.com \
    --to=jesper.nygards@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).