Skip to content

fix(parser): [[ a < b ]] compares strings, not a redirection - #2603

Merged
chaliy merged 1 commit into
mainfrom
claude/conditional-string-order
Oct 7, 2026
Merged

chaliy merged 1 commit into
mainfrom
claude/conditional-string-order

Conversation

@chaliy

@chaliy chaliy commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

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

What changed

  • < and > inside [[ ]] are string comparison operators. The conditional parser used to skip them as redirection tokens, so [[ a < B ]] silently became [[ a ]] and reported "true" for any non-empty left operand.
  • shopt listings print the option name padded to 15 columns followed by a tab, the same shape as bash (and as this crate's set -o output already used).

Why

Debian-oracle cases string-comparison-sort-order and shopt-and-set-o-listing. The comparison bug is the more serious one: a script branching on [[ "$a" < "$b" ]] took the wrong branch without any error.

Before / After

Script Before After (matches bash)
[[ a < B ]]; echo $? 0 1
[[ "" < B ]]; echo $? 1 0
[[ zzz < B ]]; echo $? 0 1
shopt extglob extglob + 25 spaces + off extglob + 8 spaces + tab + off

New spec file conditional-string-order.test.sh (3 cases), verified against bash 5.2. The shopt_show_specific case in variables.test.sh loses its bash_diff marker, since the output now matches.

Risk

Low. [[ ]] never accepted redirections, so no script could have relied on the old behavior other than by accident. Full lib, integration and bash-comparison suites pass.

Checklist

  • Failing spec first, verified against real bash
  • cargo test -p bashkit --lib, --test integration
  • cargo clippy --all-targets -D warnings, cargo fmt --check
  • knowledge/log.md updated

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 e02b1d4 Commit Preview URL

Branch Preview URL
Oct 07 2026, 10:23 PM

The conditional grammar has no redirects, so < and > inside [[ ]] are the
string comparison operators. shopt listings use bash's 15-column + tab form.

Claude-Session: https://claude.ai/code/session_019aFikmptPc91Fj4N2iDXQA
@chaliy
chaliy force-pushed the claude/conditional-string-order branch from c0f4336 to e02b1d4 Compare October 7, 2026 22:23
@chaliy
chaliy merged commit e2fc576 into main Oct 7, 2026
44 checks passed
@chaliy
chaliy deleted the claude/conditional-string-order branch October 7, 2026 22:41
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