glob
glob copied to clipboard
Notes on Glob's behaviour
Thank you for Glob! hledger uses it for including data files. Here are some notes I collected from studying Glob recently. Some of these should be documented more clearly, error-checked more thoroughly, and/or implemented, to improve overall usability. Related: #47.
- Glob does not expand tilde (
~). - It does not canonicalise the paths that it finds.
- The results are not in any particular order.
- The results can include directories.
DIRPAT/is equivalent toDIRPAT, except results will end with a double slash (//).- A
.or..path component can match the current or parent directories (potentially including them in the results). *matches zero or more characters in a file or directory name.*at the start of a path component ignores dot-named files and directories, by default.**, or any number of consecutive *'s, not followed by slash is equivalent to*.- A
**/path component matches zero or more directory parts. - A
**/ignores dot-named directories in its starting and ending directories, by default. - But
**/does search intermediate dot-named directories. Eg**/ccan finda/.b/c. I think this is a bug, and it's hard to work around with post-processing. (See #29, reportedly fixed but not for me.) - In zsh, with GLOB_STAR_SHORT enabled,
**FOOis equivalent to**/*FOO. This means**can match the start of file names as well, which is more convenient (and is how ** works eg in VS Code's file search). This could be a nice addition to Glob.