Skip to content

Fix matching logic for glob hidden files#2130

Merged
thomas-zahner merged 3 commits into
masterfrom
fix/glob-skip-hidden-files
Apr 20, 2026
Merged

Fix matching logic for glob hidden files#2130
thomas-zahner merged 3 commits into
masterfrom
fix/glob-skip-hidden-files

Conversation

@mre

@mre mre commented Apr 5, 2026

Copy link
Copy Markdown
Member

Hidden files were always included by glob patterns, even without --hidden flag. By default, shell globs exclude hidden files, but lychee behaved differently.

The trick is to pass skip_hidden to glob'smatch_opts to match shell behavior: wildcards like * and ** should not match hidden files/dirs unless --hidden is passed.

Fixes: #1937

@thomas-zahner thomas-zahner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really cool 👍

Comment thread lychee-bin/tests/cli.rs Outdated
Comment thread lychee-lib/src/types/input/resolver.rs Outdated
Hidden files were always included by glob patterns, even without
`--hidden` flag. By default, shell globs exclude hidden files, but
lychee behaved differently.

The trick is to simply pass `skip_hidden` to glob's`match_opts`.

Added two tests to make sure it works as expected:

- one test which verifies that `--dump` and `--dump-inputs` with a glob
  pattern skip hidden files, and
- one more test to make sure that `--hidden` makes glob patterns include
  hidden files
@thomas-zahner thomas-zahner force-pushed the fix/glob-skip-hidden-files branch from 5545493 to c519bee Compare April 20, 2026 09:30
@thomas-zahner thomas-zahner merged commit 27d7c4d into master Apr 20, 2026
8 checks passed
@thomas-zahner thomas-zahner deleted the fix/glob-skip-hidden-files branch April 20, 2026 09:48
@mre mre mentioned this pull request Apr 20, 2026
@mre

mre commented Apr 20, 2026

Copy link
Copy Markdown
Member Author

Thanks for the fixes @thomas-zahner. 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Hidden files are always included by glob

2 participants