Repository navigation
fix(executor): keep empty pathname components beside globstar (Refs #2709) - #3693
Merged
Merged
Conversation
…2709) GNU glob.c keeps dir_name strings verbatim: 'sub//' + '**' emits 'sub//...' names, a '**' followed by empty components ('**//x') must consume at least one real level, and 'x//y' keeps both slashes. The walk trimmed every trailing slash off the base and dropped empty segments entirely, collapsing 'sub//' to 'sub/' and letting '**//x' match top-level files. - globstar_expand keeps all but the one '**' boundary slash (glob.c:1293-1299 dir_name, glob.c:1058-1109 dir+name join) - expand_multi_globstar keeps empty segments; '**' separated from a previous '**' only by slashes still folds (glob.c:1188-1210) - collect_multi_globstar_paths tracks literal_run: an empty component contributes '/' only inside the contiguous literal prefix, and a '**' self emission keeps the literal dir's trailing separator while a matched dir emits verbatim ('x/**' -> 'x/' vs 'x/*/**' -> 'x/y') - '**' before empty components drops the cwd placeholder self match (glob.c GX_ADDCURDIR + the filename[0] rescue at glob.c:1348-1417) - '.'/'..' are literal dir components, bypassing entry matching Validated: pin issue2709_globstar_empty_component_regressions 3/3; GNU probe battery (26 cells: **//x, sub//**, sub//**//e.txt, .//**//, x//y, s*//, x/*/**, trailing slashes) byte-identical to WSL GNU 5.3.x.
This was referenced Nov 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
\*\*adjacent to empty pathname components misbehaved (issue #2709):**//*.txtwrongly matched top-level files (a.txt…); GNU requires\*\*to consume at least one real directory level when followed by//(sub/c.txt,sub/deep/e.txt,x/y/z.txtonly).sub//**/e.txtcollapsedsub//tosub/in result names; GNUemits
sub//deep/e.txt,sub//etc.Root cause
globstar_expandranprefix.trim_end_matches('/'), dropping everyempty component of the literal prefix GNU hands
glob_vectorverbatim (glob.c:1293-1299
dir_name, glob.c:1058-1109glob_dir_to_arraydir+name join).expand_multi_globstardropped all empty segments, losing both theliteral
//and the//after**that changes its arity(glob.c:1188-1210 folds only
**+/* sequences).""cwd placeholderdrop (GX_ADDCURDIR +
filename[0]rescue, glob.c:1348-1417) or for./..literal dir components.Fix
src/executor/glob.rs:**boundary slash inglobstar_expand.expand_multi_globstar; fold**+slashes+**.collect_multi_globstar_pathstracksliteral_run(a//is a real/inside the contiguous literal prefix, a boundary after glob/**)and
self_slash(**self keeps the literal dir's separator:x/**→x/,x//**→x//, butx/*/**→x/yverbatim)..self match for**followed by empty components../..bypass entry matching as literal dir components.Validation
issue2709_globstar_empty_component_regressions: 3/3 green(was 1/3 on master).
**//x,sub//**,sub//**//e.txt,.//**//e.txt,x//y,x/*/**,s*//, trailing-slash forms):byte-identical to WSL GNU Bash 5.3.x.
identical on master (
issue0015×2,issue1029×3 errexit,issue1321×4 env,issue2647,issue3205,issue332).cargo test --libred set = {issue2084} (baseline).RUSTFLAGS="-D warnings" cargo checkclean.