From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21478 invoked by alias); 23 Oct 2013 14:30:17 -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: 18057 Received: (qmail 9404 invoked from network); 23 Oct 2013 14:30:03 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW, T_TO_NO_BRKTS_FREEMAIL autolearn=ham version=3.3.2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:message-id:to:cc:subject:from:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=6EtCTAr659/cjxAMtPiW3KvHSNAQO/d+cOf7Gk9q5LA=; b=EmXEMmyPErXMA2lSX3ElfkNt8FeUH92RZUh61GjAhlN9/lj8QyCsn7jx8v0LV9jtNw JKYUombk0HTfmAjZoJiBwquar+kdIyOWC7a8X5Y5VT5kjKeHSmKCOHb0OHgSYOiiSruE cEW+jN9lJ2B36lFUSeYTWJy2wos9wHifNiyDyE14AjO8/EiBCsMkf/LrW4AJ//S90IMr hStoSB5JzB53TYFfVmjUQXQveFPMTYFDFvuGColgScSzwPpwLolNxddw/ojKlQarxR4c g2CQjq8J+opVDdznRqHr8e09gAR+VRhmZ4W5o8inqF9m6U2ZtpjgeFUTAuCBjac+499F iEcg== X-Received: by 10.68.134.133 with SMTP id pk5mr1908403pbb.89.1382538599865; Wed, 23 Oct 2013 07:29:59 -0700 (PDT) Date: Wed, 23 Oct 2013 23:29:56 +0900 (JST) Message-Id: <20131023.232956.18388131.ghostrevery@gmail.com> To: brent.briggs@gmail.com Cc: zsh-users@zsh.org Subject: Re: Glob problem From: Yuya Amemiya In-Reply-To: <91F9ED9F-B198-403B-9FE1-FF40DE960C1C@gmail.com> References: <20131023.051117.47078782.ghostrevery@gmail.com> <91F9ED9F-B198-403B-9FE1-FF40DE960C1C@gmail.com> X-Mailer: Mew version 6.3 on Emacs 23.1 / Mule 6.0 =?iso-2022-jp?B?KBskQjJWOzZOJBsoQik=?= Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Hi, > This did the job. I still have one question. I can't find any documentation for the "--" option. What does it do exactly? "--" is not a option. This separates options and normal arguments to give arguments starting with "-". The more important point is ${^path}. This turns on RC_EXPAND_PARAM option for evaluation of path. ${^path}/${~pattern} is substituted with /opt/local/bin/git*(N) /opt/local/sbin/git*(N) ... and result of substitution is interpreted as pattern for filename generation. regards, From: Brent Briggs Subject: Re: Glob problem Date: Wed, 23 Oct 2013 08:27:22 -0400 > This did the job. I still have one question. I can't find any documentation for the "--" option. What does it do exactly? > > > On Oct 22, 2013, at 4:11 PM, Yuya Amemiya wrote: > >> Hi, >> >>> print -l $path/$~pattern >> >> Try this: >> print -l -- ${^path}/${~pattern} >> >> regards >> >> From: Brent Briggs >> Subject: Re: Glob problem >> Date: Tue, 22 Oct 2013 14:49:13 -0400 >> >>> Adding the (N) Glob Qualifier made a difference but is I'm still not quite there yet. >>> >>> pattern=git*(N) >>> print -l $path/$~pattern >>> >>> Output: >>> ---------- >>> /opt/local/bin >>> /opt/local/sbin >>> /usr/bin >>> /bin >>> /usr/sbin >>> /sbin >>> /usr/local/bin >>> /usr/local/MacGPG2/bin >>> >>> This is my full path listing minus the final entry /Users/brent/bin. I know this is a bit of an incidental question but why is the final path entry missing from this output? >>> >>> Trying this gets me a little closer. >>> >>> pattern=git*(N) >>> for entry in $path >>> do >>> print -l $entry/$~pattern >>> done >>> >>> Output: >>> ---------- >>> /opt/local/bin/git >>> /opt/local/bin/git-credential-osxkeychain >>> /opt/local/bin/git-cvsserver >>> /opt/local/bin/git-receive-pack >>> /opt/local/bin/git-shell >>> /opt/local/bin/git-upload-archive >>> /opt/local/bin/git-upload-pack >>> /opt/local/bin/gitk >>> -- blank -- >>> /usr/bin/git >>> /usr/bin/git-cvsserver >>> /usr/bin/git-receive-pack >>> /usr/bin/git-shell >>> /usr/bin/git-upload-archive >>> /usr/bin/git-upload-pack >>> -- blank -- >>> -- blank -- >>> -- blank -- >>> -- blank -- >>> -- blank -- >>> >>> Blank lines are printed for the directories that contain no pattern matches. Any quick way to get rid of these? >>> >>> On Oct 22, 2013, at 2:12 PM, Peter Miller wrote: >>> >>>> On 10/22/13 14:02, Brent Briggs wrote: >>>>> Thanks for all the responses. The glob is now being generated properly. However, I am still having a problem getting my loop to run completely through. >>>>> >>>>> pattern=git* >>>>> for entry in $path >>>>> do >>>>> print -l $entry/$~pattern >>>>> done >>>>> >>>>> Output: >>>>> ---------- >>>>> /opt/local/bin/git >>>>> /opt/local/bin/git-credential-osxkeychain >>>>> /opt/local/bin/git-cvsserver >>>>> /opt/local/bin/git-receive-pack >>>>> /opt/local/bin/git-shell >>>>> /opt/local/bin/git-upload-archive >>>>> /opt/local/bin/git-upload-pack >>>>> /opt/local/bin/gitk >>>>> zsh: no matches found: /opt/local/sbin/git* >>>>> >>>>> /opt/local/sbin/ being the second entry in my path. >>>>> >>>>> >>>>> Also tried: >>>>> >>>>> print -l $path/$~pattern >>>> >>>> try >>>> >>>> pattern=git*(N) >>>> print -l $path/$~pattern >>>> >>>> that will tell zsh to ignore globs that don't have any matches. >>>> >>>>> >>>>> Output: >>>>> ---------- >>>>> zsh: no matches found: /Users/brent/bin/git* >>>>> >>>>> /Users/brent/bin/ being the last entry in my path. >>>>> >>>>> Looks like I need to use a conditional to test if any pattern matches exist, per directory, before trying to print them. I wasn't able to find a solution in the manual that facilitates testing for the existence of pattern matches. I would like to solve this problem using only globbing if possible. I am probably missing something simple. >>>>> >>>>> >>>>> >>>>> On Oct 22, 2013, at 1:05 PM, Philippe Troin wrote: >>>>> >>>>>> On Tue, 2013-10-22 at 12:45 -0400, Brent Briggs wrote: >>>>>> >>>>>>> I am simply trying to list all matches for a specified pattern in an >>>>>>> array of directory paths, the $path array for example. Here is my >>>>>>> attempt. Where am I going wrong? >>>>>> Globs are not ran after variable substitution by default. >>>>>> To run filename generation (aka globs) after variable substitution, use >>>>>> $~var. >>>>>> >>>>>> Your example: >>>>>> >>>>>>> pattern=git* >>>>>>> for entry in $path >>>>>>> do >>>>>>> # Print all files in the path that match the pattern. >>>>>>> print $entry/$pattern >>>>>>> done >>>>>> Can be rewritten as: >>>>>> >>>>>> pattern=git* >>>>>> for entry in $path >>>>>> do >>>>>> # Print all files in the path that match the pattern. >>>>>> print $entry/$~pattern >>>>>> done >>>>>> >>>>>> It can be simplified further as: >>>>>> >>>>>> pattern=git* >>>>>> print $path/$~pattern >>>>>> >>>>>> Phil. >>>>>> >>>> >>> >