zsh-users
 help / color / mirror / code / Atom feed
From: Peter Stephenson <pws@ifh.de>
To: zsh-users@sunsite.auc.dk
Subject: Re: strange glob expansion
Date: Fri, 03 Sep 1999 10:55:26 +0200	[thread overview]
Message-ID: <199909030855.KAA163997@hydra.ifh.de> (raw)
In-Reply-To: ""Bart Schaefer""'s message of "Fri, 03 Sep 1999 04:34:51 -0000." <990903043451.ZM25090@candle.brasslantern.com>

"Bart Schaefer" wrote:
> Peter's latest patches to 3.1.6 (zsh-workers 7611 and 7624) cause zsh to
> complain:
> 
> zagzig<8> echo L(*/)#
> zsh: bad pattern: L(*/)#
> 
> Zsh is being very clever here, as it's only a bad pattern in file-globbing
> context, not in string matching context:
> 
> zagzig<9> [[ Lazy//lob/ == L(*/)# ]] && echo ok
> ok

It occurs to me (finally) that maybe this is the best behaviour, since it
actually lets you know that /'s don't work in parentheses for files.  The
documented behaviour (works up to 3.1.6) is that the / is ignored and
parsing continues after the parentheses, but I guess that was simply to
note what was actually happening rather than an endorsement of it (and the
example with the z shows it was rather flakey).  I have no plans to make
/'s work in groups --- that would require large changes to both the pattern
code and the file scanning code in glob.c --- so if there is no objection
I'll just change the documentation for the new pattern matching code to
recognise the behaviour noted by Bart.

> } The upshot of this is that to match all Perl modules starting with `L'
> } below the cwd, I have to use L{*/**/*,}.pm instead of L**/*.pm.
> 
> What?  L{*/**/*,}.pm is first brace-expanded to L*/**/*.pm and L.pm, and
> then globbed.  There probably isn't an L.pm, so that matches in any sub-
> directory whose name starts with L and all its subdirectories, all the
> files whose names end with .pm.  You could have done that without the
> braces, with L*/**/*.pm, but I suspect what you meant was */**/L*.pm.

I think the answer is **/L*.pm --- as remarked by someone a day or two ago,
**/ can match (very usefully, but slightly counterintuitively given the /)
in the current directory too.  For example, in /usr/local/lib/perl5
`ls **/A*.pm' gives me:
  AnyDBM_File.pm   AutoLoader.pm    AutoSplit.pm     Text/Abbrev.pm

-- 
Peter Stephenson <pws@ifh.de>       Tel: +39 050 844536
WWW:  http://www.ifh.de/~pws/
Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy


  reply	other threads:[~1999-09-03  8:55 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-09-01  8:11 Hubert Canon
1999-09-01 17:46 ` Bart Schaefer
1999-09-02 10:15   ` Hubert Canon
1999-09-02 15:01     ` Bart Schaefer
1999-09-03  2:48       ` dado
1999-09-03  4:54         ` Bart Schaefer
1999-09-03 12:11       ` Hubert Canon
1999-09-03 14:15         ` Bart Schaefer
1999-09-03 14:34           ` Hubert Canon
1999-09-03  1:40   ` Adam Spiers
1999-09-03  4:34     ` Bart Schaefer
1999-09-03  8:55       ` Peter Stephenson [this message]
1999-09-05 21:07         ` Adam Spiers

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=199909030855.KAA163997@hydra.ifh.de \
    --to=pws@ifh.de \
    --cc=zsh-users@sunsite.auc.dk \
    /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).