feat: bash compatibility — compound arrays, grep -f, awk getline, jq env#238
Merged
feat: bash compatibility — compound arrays, grep -f, awk getline, jq env#238
Conversation
- Implement ${s/#pat/repl} prefix-anchored and ${s/%pat/repl}
suffix-anchored pattern replacement
- Implement ${var:?"msg"} error expansion with exit code 1
- Handle \/ escape in pattern replacement parsing
- Add read builtin -r flag (raw mode, no backslash interpretation)
and -p flag parsing
- Add 31 new bash spec tests:
- heredoc.test.sh (9): variable expansion, quoted delimiters,
file redirects, command/arithmetic substitution
- string-ops.test.sh (15): prefix/suffix replace, :?, :+,
case conversion, indirect expansion, negative substring
- read-builtin.test.sh (7): IFS splitting, -r flag, here-string
- Bash spec tests: 741 total, 735 pass, 6 skip (100% pass rate)
- Bash comparison: 668/668 match real bash (100%)
https://claude.ai/code/session_012rzB3FRw7yoQWCG1mxyW7J
Lexer now keeps `var=([key]=val ...)` as a single token so the
interpreter's existing compound-assignment handler receives the full
expression. Only activates when the first non-whitespace char after
`=(` is `[`, preserving the existing token-by-token path for indexed
arrays like `arr=("hello world")`.
Unskips assoc_declare_inline spec test; adds 3 more compound-init
test cases and 2 lexer unit tests.
https://claude.ai/code/session_012rzB3FRw7yoQWCG1mxyW7J
- grep -f without a positional pattern now works (was erroring with "missing pattern" because parse required a positional even when -f was set) - Rewrote grep_recursive spec test to actually create files and verify recursive directory traversal - Rewrote grep_pattern_file spec test to create pattern file first - Added negative tests: grep_recursive_no_match, grep_pattern_file_no_match https://claude.ai/code/session_012rzB3FRw7yoQWCG1mxyW7J
- Implement `getline` statement: reads next input record into $0, updates NR/NF/FNR. Refactored main loop to index-based iteration so getline can advance the line pointer. - Unskip awk_ors: workaround spec runner trailing newline by appending `; echo` (ORS itself was already implemented correctly) - Unskip awk_missing_field: rewrote test to verify empty string via conditional instead of relying on empty expected output - Unskip awk_getline: basic getline now works - Add 3 new getline spec tests (updates_dollar_zero, at_eof, three_lines) - Add 3 new getline unit tests (basic, updates_fields, at_eof) https://claude.ai/code/session_012rzB3FRw7yoQWCG1mxyW7J
jaq's built-in `env` function reads from std::env::vars() which doesn't see bashkit's virtual environment. Fix: temporarily expose ctx.env and ctx.variables to the process environment before running jaq, with an RAII drop guard for cleanup on all return paths. - Unskip jq_env spec test - Add jq_env_missing and jq_env_in_pipeline spec tests - Add test_jq_env_access and test_jq_env_missing_var unit tests https://claude.ai/code/session_012rzB3FRw7yoQWCG1mxyW7J
Replace per-value empty inputs iterator with a shared RcIter over all parsed JSON values. Main loop and filter's input/inputs functions consume from the same source, matching real jq behavior. - Unskip jq_input and jq_inputs spec tests - Add jq_input_with_dot, jq_inputs_empty spec tests - Add 3 unit tests (input_reads_next, inputs_collects_remaining, inputs_single_value) https://claude.ai/code/session_012rzB3FRw7yoQWCG1mxyW7J
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.
Summary
declare -A m=([k]=v)now tokenized as single word; lexer peeks for[after=(to distinguish from indexed arrays-fis specified; unskip grep -r and grep -f tests with proper VFS file setupgetlinestatement with index-based iteration; fix ORS and missing-field test expectationsenvbuiltin works; RAII drop guard for cleanup on all return pathsTest plan
cargo clippy --all-targets --all-features -- -D warningscleancargo test --all-features— all pass (69 lib + 101 doc)cargo test --test spec_tests— 13 suites green