From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25828 invoked by alias); 23 Oct 2013 12:27:36 -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: 18053 Received: (qmail 717 invoked from network); 23 Oct 2013 12:27:31 -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 autolearn=ham version=3.3.2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=content-type:mime-version:subject:from:in-reply-to:date :content-transfer-encoding:message-id:references:to; bh=3Yenz0djGYs6hRMHLHFHMXv41KuxEQCZjJm6ZXzTFKg=; b=hZ9DSGdfHesC6HyhrOV2Y7bQeRr6de9Xi8sb/wHMtkJL8bSkmXfz23xext81yuWCJB C8F7QLdVGANe4nwhjbCjEzu/XCel8gOQSVCpqAcNn2e3vCSeCbnmaLYc7DdOOslqt/LH SYhWNHBUMtt8Rr8Xe3vTWSnP2BiuShUsvEvHWIRimASfDW/fSyDUhlddZM1O8wJKD4bd 1IQ1GSY83FINgp7Q2fyDCuKSdqN2ZYmNNaBZ4rfB/s99D8wsgCKb8p4VHbXisG2uJh6F hX3TLnvxDA4qGQwSbDQjkiFHua6RqNKe41q8U03vr2mORyuj3/3gNkos/XW0+JrMM6/F gR/A== X-Received: by 10.224.120.138 with SMTP id d10mr3554897qar.20.1382531247195; Wed, 23 Oct 2013 05:27:27 -0700 (PDT) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 6.6 \(1510\)) Subject: Re: Glob problem From: Brent Briggs In-Reply-To: <20131023.051117.47078782.ghostrevery@gmail.com> Date: Wed, 23 Oct 2013 08:27:22 -0400 Content-Transfer-Encoding: quoted-printable Message-Id: <91F9ED9F-B198-403B-9FE1-FF40DE960C1C@gmail.com> References: <65DB21EB-86B6-479C-8F25-35B9B832CFD5@gmail.com> <5266BFF6.4050004@oracle.com> <20131023.051117.47078782.ghostrevery@gmail.com> To: "zsh-users@zsh.org" X-Mailer: Apple Mail (2.1510) 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, >=20 >> print -l $path/$~pattern >=20 > Try this: > print -l -- ${^path}/${~pattern} >=20 > regards >=20 > From: Brent Briggs > Subject: Re: Glob problem > Date: Tue, 22 Oct 2013 14:49:13 -0400 >=20 >> Adding the (N) Glob Qualifier made a difference but is I'm still not = quite there yet.=20 >>=20 >> pattern=3Dgit*(N) >> print -l $path/$~pattern >>=20 >> Output: >> ---------- >> /opt/local/bin >> /opt/local/sbin >> /usr/bin >> /bin >> /usr/sbin >> /sbin >> /usr/local/bin >> /usr/local/MacGPG2/bin >>=20 >> 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?=20 >>=20 >> Trying this gets me a little closer. >>=20 >> pattern=3Dgit*(N) >> for entry in $path =20 >> do >> print -l $entry/$~pattern >> done >>=20 >> 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 -- >>=20 >> Blank lines are printed for the directories that contain no pattern = matches. Any quick way to get rid of these? >>=20 >> On Oct 22, 2013, at 2:12 PM, Peter Miller = wrote: >>=20 >>> 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. >>>>=20 >>>> pattern=3Dgit* >>>> for entry in $path >>>> do >>>> print -l $entry/$~pattern >>>> done >>>>=20 >>>> 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* >>>>=20 >>>> /opt/local/sbin/ being the second entry in my path. >>>>=20 >>>>=20 >>>> Also tried: >>>>=20 >>>> print -l $path/$~pattern >>>=20 >>> try >>>=20 >>> pattern=3Dgit*(N) >>> print -l $path/$~pattern >>>=20 >>> that will tell zsh to ignore globs that don't have any matches. >>>=20 >>>>=20 >>>> Output: >>>> ---------- >>>> zsh: no matches found: /Users/brent/bin/git* >>>>=20 >>>> /Users/brent/bin/ being the last entry in my path. >>>>=20 >>>> 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. >>>>=20 >>>>=20 >>>>=20 >>>> On Oct 22, 2013, at 1:05 PM, Philippe Troin wrote: >>>>=20 >>>>> On Tue, 2013-10-22 at 12:45 -0400, Brent Briggs wrote: >>>>>=20 >>>>>> 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. >>>>>=20 >>>>> Your example: >>>>>=20 >>>>>> pattern=3Dgit* >>>>>> for entry in $path >>>>>> do >>>>>> # Print all files in the path that match the pattern. >>>>>> print $entry/$pattern >>>>>> done >>>>> Can be rewritten as: >>>>>=20 >>>>> pattern=3Dgit* >>>>> for entry in $path >>>>> do >>>>> # Print all files in the path that match the pattern. >>>>> print $entry/$~pattern >>>>> done >>>>>=20 >>>>> It can be simplified further as: >>>>>=20 >>>>> pattern=3Dgit* >>>>> print $path/$~pattern >>>>>=20 >>>>> Phil. >>>>>=20 >>>=20 >>=20