Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Glob problem
- X-seq: zsh-users 18044
- From: Matt Garriott <matt.garriott@xxxxxxxxx>
- To: Brent Briggs <brent.briggs@xxxxxxxxx>
- Subject: Re: Glob problem
- Date: Tue, 22 Oct 2013 11:11:02 -0600
- Cc: zsh-users@xxxxxxx
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=V4wp+zHt5wZGKO4AdwUW6PoW6VX4TcsWijkJfglgONA=; b=RlIcQDy56TrfuuqddTfuQTg4aTteR2fgSaYfDyZSnn6UA3vL/fmOa1MMNVxepM5EjK Z4tl+SHFcJDhO+OPuZLv4BTGbWFkFnhdazwwWxSQPXRxHi0bUJ6WOexzF/FK7HyqcQHG mhl4QD2YHBGN5nPEF5fYzigmSAfBlWD3jQ4v0cfgbeFalp2HGQhP3f7S5mGSwrEvxV4G EaZ+XHJkPyIY9X1h078beTLI8sVK9XJOznIChxIY89+7/oAiaclEgrpvLU0uBBz8udQx X538dtS+ubqklF5jd3rfS3tMkoKU+GYMJVRza6ccRQSoy9/LG1Yj43nRicpyoqCTOsKq 9vNQ==
- In-reply-to: <F814E825-D3A5-420E-B289-6D3B0FB47D75@gmail.com>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <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*
Messages sorted by:
Reverse Date,
Date,
Thread,
Author