Skip to content

Notes on Glob's behaviour #49

@simonmichael

Description

@simonmichael

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 to DIRPAT, 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 **/c can find a/.b/c. I think this is a bug, and it's hard to work around with post-processing.
    (See ** has inconsistent behavior with hidden directories #29, reportedly fixed but not for me.)
  • In zsh, with GLOB_STAR_SHORT enabled, **FOO is 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions