Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Patterns (was Re: array filtering)



On Sun, Jun 9, 2024 at 3:15 PM Ray Andrews <rayandrews@xxxxxxxxxxx> wrote:
>
> There's regex, there's globbing and then there's shell patterns. It's not easy to keep them in separate drawers in my mind.

Almost all pattern matching (including globbing) within the shell uses
"shell patterns".  You only get into regular expressions when you
break out to external programs (grep, sed, awk, perl, etc.) or when
you specifically ask for the shell to use them (zmodload the pcre
and/or regex modules).

The only distinction with globbing is that the shell patterns apply to
file names, and therefore obey the convention of hiding file names
beginning with a "." and the file system rules about directory
hierarchies.  The latter makes "/" significant, so some extra sugar is
added to move through the tree.

Glob qualifiers apply to the file names or to characteristics of the
files they name, not to the pattern, which is why they don't mean
anything in other contexts.  The (D) qualifier, exposing hidden
dot-files, is sort of an exception, but it changes the search space
rather than the interpretation of the pattern.




Messages sorted by: Reverse Date, Date, Thread, Author