Skip to content

fix: pass malformed glob patterns through literally#180

Open
bartlomieju wants to merge 1 commit into
mainfrom
fix/glob-pattern-error-passthrough
Open

fix: pass malformed glob patterns through literally#180
bartlomieju wants to merge 1 commit into
mainfrom
fix/glob-pattern-error-passthrough

Conversation

@bartlomieju
Copy link
Copy Markdown
Member

A task command like deno run --allow-write=**/*.txt test.ts failed with
glob: no matches found ... Pattern syntax error near position N: recursive wildcards must form a single path component because the ** does not form
its own path component once joined to the --allow-write= prefix. The glob
crate rejects the pattern at compile time, and the Err arm of the match in
evaluate_word_text errored unconditionally — it did not consult
failglob / nullglob the way the empty-match arm does.

Bash's behavior is to pass a malformed pattern through literally unless
failglob is explicitly set. This change mirrors the empty-match branch
into the pattern-error branch so the default is literal pass-through, with
failglob and nullglob still respected. Includes regression tests for
both flavors from the issue (the valid-but-zero-match form and the
malformed-pattern form), plus a failglob-on case confirming the new
branch still errors when requested.

Fixes denoland/deno#27238

Bash treats malformed glob patterns the same as patterns that match
nothing: it passes them through literally unless `failglob` is set.
Previously the `Err(...)` arm of the glob compile step always errored,
which broke task commands like `deno run --allow-write=**/*.txt ...`
where the `**` does not form its own path component.

The empty-match arm already does the right thing; this just mirrors that
logic into the pattern-error arm.
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.

deno task: globstar does not work properly on task dependencies ?

1 participant