zsh-users
 help / color / mirror / code / Atom feed
From: Matt Garriott <matt.garriott@gmail.com>
To: Brent Briggs <brent.briggs@gmail.com>
Cc: zsh-users@zsh.org
Subject: Re: Glob problem
Date: Tue, 22 Oct 2013 11:11:02 -0600	[thread overview]
Message-ID: <20131022171102.GE22613@hazmatt> (raw)
In-Reply-To: <F814E825-D3A5-420E-B289-6D3B0FB47D75@gmail.com>

By default Zsh does not expand glob patterns in variables when using
parameter expansion. You can change this behavior using the GLOB_SUBST
option. Add the following line to the top of your script, and it should
work like you expect.

  setopt GLOB_SUBST

For more info check out GLOB_SUBST in `man zshoptions`

-Matt

On Tue, Oct 22, 2013 at 12:45:48PM -0400, Brent Briggs wrote:
> Hello Zsh masters,
> 
> 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?
> 
> pattern=git*
> for entry in $path
> do
>     # Print all files in the path that match the pattern. 
>     print $entry/$pattern
> done
> 
> Expected/Desired 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
> /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
> 
> Actual Output:
> -------------------
> /opt/local/bin/git*
> /opt/local/sbin/git*
> /opt/local/bin/git*
> /opt/local/sbin/git*
> /usr/bin/git*
> /bin/git*
> /usr/sbin/git*
> /sbin/git*
> /usr/local/bin/git*
> /usr/local/MacGPG2/bin/git*
> /Users/brent/bin/git*
> /Users/brent/bin/git*


      parent reply	other threads:[~2013-10-22 17:11 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-22 16:45 Brent Briggs
2013-10-22 16:58 ` Jérémie Roquet
2013-10-22 16:59 ` Peter Stephenson
2013-10-22 17:05 ` Philippe Troin
2013-10-22 18:02   ` Brent Briggs
2013-10-22 18:12     ` Peter Miller
2013-10-22 18:49       ` Brent Briggs
2013-10-22 19:30         ` Peter Miller
2013-10-22 20:11         ` Yuya Amemiya
2013-10-23 12:27           ` Brent Briggs
2013-10-23 12:37             ` Jérémie Roquet
2013-10-23 13:47             ` Peter Stephenson
2013-10-23 14:29             ` Yuya Amemiya
2013-10-22 17:11 ` Matt Garriott [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=20131022171102.GE22613@hazmatt \
    --to=matt.garriott@gmail.com \
    --cc=brent.briggs@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).