1

I quite like mercurial .hgignore-style pattern globbing.

Globs are rooted at the current directory; a glob such as *.c will only match files in the current directory ending with .c.

The supported glob syntax extensions are ** to match any string across path separators and {a,b} to mean "a or b".

Is there a Linux shell that supports this?

1
  • The section you quote is actually not about the .hgignore ignore patterns — they're not rooted for example. The section is about the general pattern supported by all commands. You use them like hg add "set:**.c", which works even when your shell doesn't (e.g., on Windows). Jun 20, 2013 at 6:59

1 Answer 1

2

All shells will support the standard glob *.c. KSH, Bash, and ZSH support brace expansion ({a,b}), but note that this not a file glob, so it will always expand. ZSH's extended globbing and Bash's globstar (bash v4 or higher), support ** for recursive globbing.

5
  • brace expansion originates in csh, ** comes from zsh (1991) and is now supported by ksh93 and tcsh. Also with bash and fish but with the caveat that they follow symlinks when recursing. zsh and tcsh have *** to follow symlinks. Jun 19, 2013 at 21:25
  • @StephaneChazelas I tested ** in ksh93 without the expected results. Does it require enabling a feature like globstar in bash?
    – jordanm
    Jun 19, 2013 at 21:29
  • 1
    yes, they all do except zsh. set -G in ksh93. bash got it from ksh93 as most things. See also that answer Jun 19, 2013 at 21:47
  • @jordanm Thank you for suggesting Bash globstar. It is especially the recursive ** that I am after. Jun 19, 2013 at 21:58
  • In Bash you can use shopt -s nullglob as well to avoid getting literally *.c if there is no file match.
    – l0b0
    Jun 20, 2013 at 8:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .