zsh-users
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Zsh Users <zsh-users@zsh.org>
Subject: Re: mapfile, many files and globbin
Date: Mon, 3 Jun 2013 08:44:50 -0700	[thread overview]
Message-ID: <CAH+w=7aDh+Q4GjpGm4=ekhxUtOXJZk0nmwN3UgSrHa9heVZ_Zg@mail.gmail.com> (raw)
In-Reply-To: <CAC7-vpCQajB9OFer41GAtrf3-uTxx856fasr7MWu2w+akJjUZg@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1086 bytes --]

On Mon, Jun 3, 2013 at 7:00 AM, Wawrzek Niewodniczanski
<main@wawrzek.name>wrote:

> Hi,
>
> Is it possible to mix mapfile module and globbing (for file names)?
>

Partly, but not in the way you want.  You can mix mapfile and pattern
matching but not mapfile and glob flags that reference on-disk file
attributes, including recursive directory descent.  So in your example:

names=("${(f)mapfile[TEST/**/*list(.L+0)]}")
>

The **/ and (.L+0) won't work.  mapfile is just an associative array, so
you can only do associative array key matching in the subscript expression.
 Also, the keys of $mapfile that you can examine are limited to the names
of files in the current working directory, and you can't [in a single
non-nested parameter expression] expand the contents of a file name matched
by a subscript pattern.

Similarly ${mapfile[(R)pattern]} will not do a grep for you.

However, you can invert the problem and mix globbing with mapfile.

names=( TEST/**/*list(.L+0e:'reply=(${(f)mapfile[$REPLY]})':) )

If you don't want the results sorted, you may need some additional flags.

  reply	other threads:[~2013-06-03 15:44 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-03 14:00 Wawrzek Niewodniczanski
2013-06-03 15:44 ` Bart Schaefer [this message]
2013-06-05 21:30   ` Wawrzek Niewodniczanski
2013-06-06  6:17     ` Bart Schaefer

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='CAH+w=7aDh+Q4GjpGm4=ekhxUtOXJZk0nmwN3UgSrHa9heVZ_Zg@mail.gmail.com' \
    --to=schaefer@brasslantern.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).