Expand description
Exclude-pattern expansion and matching, plus the follow/no-follow setting.
The oracle (snapdir-manifest) applies excludes as an extended regular
expression fed to grep -E -v: a path is excluded when the regex matches
it. The user-supplied --exclude pattern may embed two macros that expand
to built-in sets, lifted verbatim from _snapdir_manifest_define_exclude_patterns:
%system%expands to the system directory set and forces--no-follow.%common%expands to the common directory set (.git,.cache,node_modules,.DS_Store, Trash dirs, …).
Per the library-purity principle, snapdir-core reads no environment.
The oracle’s %system% set interpolates two runtime paths — ${HOME}/.cache/
and the resolved cache directory ${_SNAPDIR_MANIFEST_CACHE_DIR} — so those
are passed in as parameters; the CLI lane resolves $HOME / XDG_CACHE_HOME
and hands them to expand_excludes. The built-in literal sets themselves
match the oracle’s hard-coded defaults (when SNAPDIR_SYSTEM_EXCLUDE_DIRS /
SNAPDIR_COMMON_EXCLUDE_DIRS are unset).
The filesystem walk that actually consults ExcludeMatcher::is_excluded
lands in a later gate; this module models the expansion + matcher + the
follow/no-follow option semantics, validated against the Bash source.
Structs§
- Exclude
Matcher - A compiled exclude matcher: a path is excluded when the (extended) regex
matches anywhere in it, mirroring
grep -E -v. - Expanded
Exclude - The result of expanding a
--excludepattern: the final extended-regex string plus whether the expansion forced--no-follow.
Enums§
- Exclude
Error - Errors raised while expanding/compiling an exclude pattern.
- Follow
Mode - Whether the filesystem walk follows symbolic links.
Constants§
- COMMON_
EXCLUDE_ DIRS - The oracle’s default common exclude directory list — the body of
SNAPDIR_COMMON_EXCLUDE_DIRS’s default. - SYSTEM_
EXCLUDE_ DIRS - The oracle’s default system exclude directory list — the body of
SNAPDIR_SYSTEM_EXCLUDE_DIRS’s default (the leading-^-anchored set, excluding the trailing${HOME}/.cache/and cache-dir entries, which are runtime values appended inexpand_excludes).
Functions§
- expand_
excludes - Expands the
%system%/%common%macros in a--excludepattern.