Skip to content

Case in command support#1053

Open
lu-zero wants to merge 3 commits into
reubeno:mainfrom
lu-zero:case-in-command
Open

Case in command support#1053
lu-zero wants to merge 3 commits into
reubeno:mainfrom
lu-zero:case-in-command

Conversation

@lu-zero

@lu-zero lu-zero commented Mar 15, 2026

Copy link
Copy Markdown
Contributor

Fixes #1052

lu-zero added 2 commits March 14, 2026 23:27
Add case_statement rule to PEG word parser to correctly parse case
statements inside command substitutions. This is a temporary fix until
the PEG parser is replaced by winnow for word expansion.

Adds test case for case statement inside command substitution.
Track case statement state while tokenizing nested constructs to prevent
incorrectly treating ')' in case patterns as the end of command substitution.

Fixes parsing of constructs like:
  echo $(case a in a) echo ok ;; esac)
@github-actions

github-actions Bot commented Mar 15, 2026

Copy link
Copy Markdown

Performance Benchmark Report

Benchmark name Baseline (μs) Test/PR (μs) Delta (μs) Delta %
clone_shell_object 17.41 μs 17.02 μs -0.39 μs 🟢 -2.22%
eval_arithmetic 0.15 μs 0.15 μs 0.00 μs ⚪ Unchanged
expand_one_string 1.56 μs 1.56 μs 0.00 μs ⚪ Unchanged
for_loop 25.65 μs 25.57 μs -0.07 μs ⚪ Unchanged
full_peg_complex 58.67 μs 57.73 μs -0.94 μs ⚪ Unchanged
full_peg_for_loop 6.32 μs 6.29 μs -0.03 μs ⚪ Unchanged
full_peg_nested_expansions 16.75 μs 16.38 μs -0.38 μs 🟢 -2.24%
full_peg_pipeline 4.38 μs 4.31 μs -0.07 μs ⚪ Unchanged
full_peg_simple 1.83 μs 1.85 μs 0.01 μs ⚪ Unchanged
function_call 2.75 μs 2.77 μs 0.01 μs ⚪ Unchanged
instantiate_shell 55.88 μs 54.59 μs -1.30 μs 🟢 -2.32%
instantiate_shell_with_init_scripts 26514.60 μs 25304.36 μs -1210.24 μs 🟢 -4.56%
parse_peg_bash_completion 2104.90 μs 2080.52 μs -24.39 μs 🟢 -1.16%
parse_peg_complex 20.34 μs 20.09 μs -0.26 μs 🟢 -1.25%
parse_peg_for_loop 2.03 μs 2.02 μs -0.01 μs ⚪ Unchanged
parse_peg_pipeline 2.26 μs 2.21 μs -0.05 μs ⚪ Unchanged
parse_peg_simple 1.13 μs 1.12 μs -0.01 μs ⚪ Unchanged
run_echo_builtin_command 17.93 μs 17.88 μs -0.04 μs ⚪ Unchanged
tokenize_sample_script 3.37 μs 3.38 μs 0.00 μs ⚪ Unchanged

Code Coverage Report: Only Changed Files listed

Package Base Coverage New Coverage Difference
brush-builtins/src/complete.rs 🟢 83.38% 🟢 75.06% 🔴 -8.32%
brush-builtins/src/declare.rs 🟢 86.6% 🟢 86.33% 🔴 -0.27%
brush-builtins/src/unset.rs 🟢 90.2% 🟢 88.24% 🔴 -1.96%
brush-core/src/commands.rs 🟢 91.7% 🟢 91.48% 🔴 -0.22%
brush-core/src/completion.rs 🟠 73.25% 🟠 72.02% 🔴 -1.23%
brush-core/src/expansion.rs 🟢 95.43% 🟢 95.36% 🔴 -0.07%
brush-core/src/extendedtests.rs 🟠 74.75% 🟠 73.23% 🔴 -1.52%
brush-core/src/extensions.rs 🔴 0% 🟢 100% 🟢 100%
brush-core/src/results.rs 🟢 83.33% 🟢 80.16% 🔴 -3.17%
brush-core/src/variables.rs 🟢 89% 🟢 88.83% 🔴 -0.17%
brush-parser/src/tokenizer.rs 🟢 93.41% 🟢 93.4% 🔴 -0.01%
brush-test-harness/src/execution.rs 🟢 79.26% 🟢 80.85% 🟢 1.59%
Overall Coverage 🟢 75.11% 🟢 74.94% 🔴 -0.17%

Minimum allowed coverage is 70%, this run produced 74.94%

Test Summary: bash-completion test suite

Outcome Count Percentage
✅ Pass 1580 74.92
❗️ Error 18 0.85
❌ Fail 157 7.44
⏩ Skip 339 16.07
❎ Expected Fail 13 0.62
✔️ Unexpected Pass 2 0.09
📊 Total 2109 100.00

@reubeno reubeno added state: needs review PR or issue author is waiting for a review area: parsing Issues or PRs related to tokenization or parsing area: compat Related to compatibility with standard shells labels Mar 15, 2026
@lu-zero

lu-zero commented Mar 29, 2026

Copy link
Copy Markdown
Contributor Author

sigh, probably would be easier to get it sorted once we use only the winnow parser.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: compat Related to compatibility with standard shells area: parsing Issues or PRs related to tokenization or parsing state: needs review PR or issue author is waiting for a review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

$(case ... in pattern) ...) — ) in case pattern misinterpreted as command substitution terminator

2 participants