Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Glob problem



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*



Messages sorted by: Reverse Date, Date, Thread, Author