help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-bash] Filename Expansion: Find Utility vs Bash Shell Pattern M


From: Stephane Chazelas
Subject: Re: [Help-bash] Filename Expansion: Find Utility vs Bash Shell Pattern Matching
Date: Thu, 18 Jun 2015 14:12:34 +0100
User-agent: Mutt/1.5.21 (2010-09-15)

2015-06-17 14:10:45 -0400, Greg Wooledge:
[...]
> Then one day, some people decided this was confusing nonsense, and
> standardized the world of regular expressions into two kinds: Basic (BRE)
> and Extended (ERE).  Now, grep and sed use BREs, and grep -E uses EREs.
> Bash's =~ operator also uses EREs.  So, when you're looking at someone
> else's program that uses a BRE or an ERE, you have a small chance of
> being able to understand what it does.

That's not a very accurate account of RE history.

Some extra operators were added independantly in various regex
engines for various commands on various sytems, most of the time
in backward compatible fashion to the basic ^$.[* subset but not
necessarily between each other.

egrep and awk introduced a new incompatible RE syntax in V7
(79).

Those two main variants have received extensions over the years
and that still carries on. perl REs extend those EREs (though
perl REs are not strickly compatible in the way their
alternation operator works for instance). \{ was added to BRE
before { was added to EREs IIRC (breaking backward compatibility
there, and not for BRE). \< was added to some BRE engines, not <
for ERE...

POSIX did standardise some BRE and ERE operators, but that
doesn't stop GNU/perl/BSDs/AT&T/TRE/vim/emacs from adding their
own extensions.

> (Then perl happened, and broke everything all over again, but that's a
> different chapter.)

perl happened before POSIX standardized BREs and EREs AFAIK.

> That same unification has NOT taken place for glob patterns.  Every
> implementation of globbing is slightly different.  There are no standards.
> You seem to be asking "which library function does ___ use" as if that
> would reveal the answer to the your real question "to which globbing
> standard does ____ conform", but there are no such standards in the
> first place.
[...]

POSIX specifies fnmatch patterns and shell globs just like it
does REs. And many implementatins have extensions. I don't see
any difference here.

> Right now, you just have to learn each program's features one by one.
[...]

Or make do with the minimal set specified by POSIX just like for
REs (?, *, []).

-- 
Stephane




reply via email to

[Prev in Thread] Current Thread [Next in Thread]