From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2747 invoked by alias); 7 Jun 2016 06:59:04 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 21623 Received: (qmail 11623 invoked from network); 7 Jun 2016 06:59:03 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, HTML_MESSAGE,T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to; bh=BeqkhS/nhLZqH357xZKqLFOakJq3bbNys9QXjjtexkw=; b=Jz5l0bwRqwilxoHiusZR+sbLg3iGUWiVcYSOySG7+5xUSM1kURdB9nf0JbzWEwDKgV CjHNjsHrQTOdBBSMpZ9zPtqyPlCkh0PZ9dBhOmD9qbzv8T7GZKMwrAT0dE7mNsOUU9AN /XsVrqcq3NYgVeZCpTtVqUmeRfrsb/z/6jwqBvcWpDm5OczSmfe8sFoNCuvnVXkM0lqe tj2xA9CFGgO8CPadaoAjLTKPz8sJT2adtvhSY//1+/ZCI7Y9859eRxYazO47fGKRi2jZ rIaJ5RCkDn3unb6kZmTBc9bmdYbFWwF4Owd305LpNayzviuvwSCqAY1Cf8Co5RxlweUW /BGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=BeqkhS/nhLZqH357xZKqLFOakJq3bbNys9QXjjtexkw=; b=Y1o/xi3Y5BRkmPzdzZGOYCLEPK4Wplgp6tSwHZMccv+LehSouyPba0H0oUNauh+Od7 bEQcJeicgCzLezv54uWED2Vlxgr956wL4MvNiOpKq0Ht/rfCjNsXdl2GChM+PZOFdXc8 jP70LghKSioXUe7G3ZPrk8gH5LsmHER8Za90BsymvrFppDJ7QsXK7X2OxjDL7FTrs7RW tiFQ0S9Eg/5jf7CXIHUl6OgYWxGgROaUshaP4jCFFs9NdyJUi5E6wbfmQmdjX4ltTnzI 56CqZDCaxiC8Ym7EIrXnJcH1iR/qvtwgLUNQSwGM6vOLjWNdkvTvelmEuJLxHAV+pglb FTJw== X-Gm-Message-State: ALyK8tJM1cVwVLODtb9w2OgEPilGhSDKrSL7VCqcVxS9aS8PRPuzqxOrS+1persKwfSd3TYnFRLD0oqIbbCPZw== X-Received: by 10.25.3.12 with SMTP id 12mr1581056lfd.110.1465282740757; Mon, 06 Jun 2016 23:59:00 -0700 (PDT) MIME-Version: 1.0 From: =?UTF-8?Q?Jesper_Nyg=C3=A5rds?= Date: Tue, 7 Jun 2016 08:58:59 +0200 Message-ID: Subject: A minor syntax question To: Zsh Users Content-Type: multipart/alternative; boundary=001a113ec466422bd90534aab9a5 --001a113ec466422bd90534aab9a5 Content-Type: text/plain; charset=UTF-8 I am writing a function that's basically a wrapper to an invocation of 'find'. I have the need to transform some arguments to my function into an expression I pass on to 'find'. Here's a simplified example of what I want to do: xff() { zparseopts -D -E t+:=types || return 1 typearg="("${"$(print -- '-o -type '${^types:#-t})"#-o }")" print $typearg } What I want to do is to construct a nested expression for the variable number of file types that can be given. They should be contained within parenthesis, and joined by "-o". So, for example: xff -t f -> "(-type f)" xff -t f -t d -> "(-type f -o -type d)" As you can see, my function strips away the '-t' elements, then expands the parameter list with '-o -type ' before each element, and finally strips 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. At the same time, I'm rather happy with having found a one-liner expressing what I want. So my question is: is there a more elegant way of solving this which is still compact? --001a113ec466422bd90534aab9a5--