zsh-users
 help / color / mirror / code / Atom feed
From: Philippe Troin <phil@fifi.org>
To: Brent Briggs <brent.briggs@gmail.com>
Cc: zsh-users@zsh.org
Subject: Re: Glob problem
Date: Tue, 22 Oct 2013 18:05:34 +0100	[thread overview]
Message-ID: <1382461534.20462.9.camel@air.home.fifi.org> (raw)
In-Reply-To: <F814E825-D3A5-420E-B289-6D3B0FB47D75@gmail.com>

On Tue, 2013-10-22 at 12:45 -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?

Globs are not ran after variable substitution by default.
To run filename generation (aka globs) after variable substitution, use
$~var.

Your example:

> pattern=git*
> for entry in $path
> do
>     # Print all files in the path that match the pattern. 
>     print $entry/$pattern
> done

Can be rewritten as:

        pattern=git*
        for entry in $path
        do
            # Print all files in the path that match the pattern. 
            print $entry/$~pattern
        done
        
It can be simplified further as:

        pattern=git*
        print $path/$~pattern

Phil.


  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 [this message]
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

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=1382461534.20462.9.camel@air.home.fifi.org \
    --to=phil@fifi.org \
    --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).