From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10562 invoked by alias); 22 Oct 2013 18:02:30 -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: 18047 Received: (qmail 11139 invoked from network); 22 Oct 2013 18:02:25 -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:cc :message-id:references:to; bh=CNE/gx2I84IfGsdaXFJisDgViwgCvToSubnEWbBQixo=; b=i6GrQPxd98GoTDrp4Cw5kZkkQS6t68NNeHwd1V4g3sbjXwZWCf+jRdGKgegGu7sLdO yJnpFdWqwHQxCJZbq8m/yFopBdEwF43qg2bKojMc6CzWNpIFZV7CpswnN4rnlvrRIDtI aIpWGv0BWG1hIdODCD2NVbxif1muvxdoouuLYyrbhVkeenPrFtgEPTWVJKixofu9rsbt U1gFrFeou9PW7z2jWbBh/ZfwTNc7GHhD1rRsb9WO3DqOWT0mZofx1d1/wltqqMgq7PUu asbBJC6pJdNkO+6cS4P2PNI/gyIM8eWVsFyjNF3dXbrSrPWex9HUljvjuWtNq9uXW9ie GcXQ== X-Received: by 10.49.30.66 with SMTP id q2mr31464971qeh.38.1382464942628; Tue, 22 Oct 2013 11:02:22 -0700 (PDT) Content-Type: multipart/signed; boundary="Apple-Mail=_2F31476A-6C80-4547-B507-4EFEE3D558F3"; protocol="application/pgp-signature"; micalg=pgp-sha1 Mime-Version: 1.0 (Mac OS X Mail 6.6 \(1510\)) Subject: Re: Glob problem From: Brent Briggs In-Reply-To: <1382461534.20462.9.camel@air.home.fifi.org> Date: Tue, 22 Oct 2013 14:02:19 -0400 Cc: zsh-users@zsh.org Message-Id: <65DB21EB-86B6-479C-8F25-35B9B832CFD5@gmail.com> References: <1382461534.20462.9.camel@air.home.fifi.org> To: Philippe Troin X-Mailer: Apple Mail (2.1510) --Apple-Mail=_2F31476A-6C80-4547-B507-4EFEE3D558F3 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii 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=3Dgit* 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 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: >=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? >=20 > 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.=20 >> print $entry/$pattern >> done >=20 > Can be rewritten as: >=20 > pattern=3Dgit* > for entry in $path > do > # Print all files in the path that match the pattern.=20 > print $entry/$~pattern > done >=20 > It can be simplified further as: >=20 > pattern=3Dgit* > print $path/$~pattern >=20 > Phil. >=20 --Apple-Mail=_2F31476A-6C80-4547-B507-4EFEE3D558F3 Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=signature.asc Content-Type: application/pgp-signature; name=signature.asc Content-Description: Message signed with OpenPGP using GPGMail -----BEGIN PGP SIGNATURE----- Comment: GPGTools - http://gpgtools.org iQIcBAEBAgAGBQJSZr2rAAoJEIK6HyL8pOMU8Y0P/3cqsViqfhDnYFfMyW0ZVjYr 89Cua42Eaer5ooOepxAkkWPaU5nlchgVqmznmOtflRR623ddxb2BIYFjitBCdVyW 14s9cdAsaHaecXHDLybA7AEdnO7aGXOKMPiJeTNeV0d2srewZh1U6UwVZF66jQqR e6K2sOb0+deTmhx7yknShezmBkm6kzoJQGVTnS1OJK+W/hRI1pnvdBepkeogX5Lx wlXFN1KL0uzbL89aE/rJBX3G8RYsS02/WBOAaoDlSqjnmc1lBNjs2J2FTaP9nbV6 QI1yaaYB/dLUmcdI5f9D7JrdWBLaylW2AcDFK3qMfHyGUGrhk7h1IYxjhaQ2dyEp rO01/kIGo4tq3VseT2xZ7EEhiZyxIW6E2de6+RkzHiXSGaOsLjnuJAP9ZW37kYv2 CXaIU4Mi1NHrarLJuVRxUnEKwEu+2nBkGvBH+QAZ5pvz2OkcqurZK8E+W22S+1p2 UN5R10daNjKgvxPFuiVM7a/3D2lIhWmp/lJ1D26D9+7/se3AXpqPgFMKtIIk9EXx BUQ3dK9sS4As5AQwjMmiKR8pnsZsgnArmu0Jq9O9UgQ4e4GFSQiunIwXUd8H5ibF h7EO++KFuEjF2WIVWeXSUq7P7njLlgdvvrUseFuqkRqQIMwIES83U4bFA+oNvNqs 6JDEljW4x4ehjYnIBdb+ =ou37 -----END PGP SIGNATURE----- --Apple-Mail=_2F31476A-6C80-4547-B507-4EFEE3D558F3--