From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7771 invoked by alias); 22 Oct 2013 17:09:51 -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: 18043 Received: (qmail 23185 invoked from network); 22 Oct 2013 17:09:35 -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=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI, SPF_HELO_PASS autolearn=ham version=3.3.2 X-AuditID: cbfec7f4-b7f0a6d000007b1b-9a-5266aef0f5e7 Date: Tue, 22 Oct 2013 17:59:27 +0100 From: Peter Stephenson To: Brent Briggs , zsh-users@zsh.org Subject: Re: Glob problem Message-id: <20131022175927.6de9a441@pwslap01u.europe.root.pri> In-reply-to: References: Organization: Samsung Cambridge Solution Centre X-Mailer: Claws Mail 3.7.9 (GTK+ 2.22.0; i386-redhat-linux-gnu) MIME-version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprCLMWRmVeSWpSXmKPExsVy+t/xy7of1qUFGUyfxm2x772oxY6TKxkd mDx2zrrL7rHq4AemAKYoLpuU1JzMstQifbsErowfa1UK3nNUHN98mL2B8RNbFyMnh4SAicTn iWuZIWwxiQv31oPFhQSWMkq8XGbdxcgFZPczSaxefIsVJMEioCoxfdIfFhCbTcBQYuqm2Ywg toiAjcS8t+vZQWxhAUmJ03Pfg9XzCthLXHi1EszmFLCV6L++ixVigY3EtsnnwOr5BfQlrv79 xARxhL3EzCtnGCF6BSV+TL4HtotZQEti87YmVghbXmLzmrfMExgFZiEpm4WkbBaSsgWMzKsY RVNLkwuKk9JzDfWKE3OLS/PS9ZLzczcxQkLyyw7GxcesDjEKcDAq8fA+aEkLEmJNLCuuzD3E KMHBrCTC2+wLFOJNSaysSi3Kjy8qzUktPsTIxMEp1cAY6dXz7+uFyibJJfV1R1MkZ3/cvKIk 8tGjZLPVQusyVrY8mVHRf3BP09EMYf9qF2elvvZvr13W+sqdU7085/uUNz+W/60W176leKP1 CS+XStxm61PTXfwU3mwMW23O+rwiTOGB4WQls8x0E+UXVhnnH7+OnH++zuX5rq8vqoKqQo/W zFH9J2uhxFKckWioxVxUnAgAcfeNqScCAAA= On Tue, 22 Oct 2013 12:45:48 -0400 Brent Briggs wrote: > 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? I'm sure someone will beat me to it... > pattern=git* It's not the source of the problem, but it's generally safer to quote literal patterns if you don't want them expanded at that point. Actually, you can't get a glob here unless you have the GLOB_ASSIGN option set. > for entry in $path > do > # Print all files in the path that match the pattern. > print $entry/$pattern > done $pattern is the literal string "git*" in zsh and doesn't get expanded further. If you like the way other shells work, use (globally) setopt globsubst However, most of us find it a pain having to remember to quote variables every time we we want them to be substituted literally (which most other languages would do automatically). The zsh-specific way to tell it you want pattern characters to be special is: print $entry/${~pattern} pws