Skip to content

fix(expansion): match ?, multi-star and lone * in ${x#pat} and ${x%pat} - #2565

Merged
chaliy merged 1 commit into
mainfrom
claude/remove-prefix-empty-match
Oct 7, 2026
Merged

chaliy merged 1 commit into
mainfrom
claude/remove-prefix-empty-match

Conversation

@chaliy

@chaliy chaliy commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Requested by Михайло · project thread

What changed

${x#pat}, ${x##pat}, ${x%pat} and ${x%%pat} follow the glob grammar:

  • A lone * matches the empty string for the short forms.
  • Patterns with ? or several * go through glob_match.
  • Single-* patterns keep the linear fast path.

Why

${x#*} and ${x%*} dropped a character. ${x%?} (strip the last character), ${p#*/*/} and ${p##*.*.} were compared as literal text and removed nothing.

Before

x=abc; echo "${x#*}|${x%*}|${x%?}|${x#*?}"   ->  bc|ab|abc|abc
p=/a/b.c/d.tar.gz; echo "${p#*/*/}|${p##*.*.}"  ->  /a/b.c/d.tar.gz|/a/b.c/d.tar.gz

After

abc|abc|ab|bc
b.c/d.tar.gz|gz

The new spec remove-pattern-glob.test.sh matches real bash.

Risk

Low. The new patterns use the existing capped remove_pattern_glob (TM-DOS cap).

Checklist

  • Spec compared with bash; failed before
  • lib + integration tests, clippy, fmt
  • knowledge/log.md

https://claude.ai/code/session_019aFikmptPc91Fj4N2iDXQA


Generated by Claude Code

@chaliy chaliy self-assigned this Oct 7, 2026
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
bashkit ad80231 Commit Preview URL

Branch Preview URL
Oct 07 2026, 03:41 PM

@chaliy
chaliy force-pushed the claude/remove-prefix-empty-match branch 2 times, most recently from 86d92b5 to 1dcac3d Compare October 7, 2026 14:50
@chaliy
chaliy force-pushed the claude/remove-prefix-empty-match branch from 1dcac3d to ad80231 Compare October 7, 2026 15:40
@chaliy
chaliy merged commit 7322206 into main Oct 7, 2026
44 checks passed
@chaliy
chaliy deleted the claude/remove-prefix-empty-match branch October 7, 2026 15:59
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.

1 participant