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?

Serge Stroobandt
  • 2,314
  • 3
  • 32
  • 36
  • 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). – Martin Geisler Jun 20 '13 at 06:59

1 Answers1

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.

jordanm
  • 41,988
  • 9
  • 116
  • 113
  • 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. – Stéphane Chazelas Jun 19 '13 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 '13 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](http://unix.stackexchange.com/a/62665/22565) – Stéphane Chazelas Jun 19 '13 at 21:47
  • @jordanm Thank you for suggesting Bash `globstar`. It is especially the recursive `**` that I am after. – Serge Stroobandt Jun 19 '13 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 '13 at 08:13