feat(bash): arithmetic exponentiation, base literals, mapfile#241
Merged
feat(bash): arithmetic exponentiation, base literals, mapfile#241
Conversation
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
- Arithmetic ** (power) operator with correct precedence over * - Base#value literals (16#ff, 2#1010, 8#77) and 0x/077 prefixes - Unary operators: !, ~, - in arithmetic expressions - mapfile/readarray builtin with -t flag and custom array name - expand_arithmetic_vars tracks numeric literal context to avoid expanding hex digits as variable names - 13 new spec tests (10 arithmetic, 3 mapfile) https://claude.ai/code/session_012rzB3FRw7yoQWCG1mxyW7J
…n, heredoc <<-
Arithmetic evaluation:
- Bitwise XOR (^), left/right shift (<<, >>)
- Compound assignments (+=, -=, *=, /=, %=, &=, |=, ^=, <<=, >>=)
- Pre/post increment/decrement (++x, x++, --x, x--)
- Comma operator for multi-expression evaluation
- Fix C-style for loop with <= and >= conditions
Shell features:
- trap builtin with EXIT handler support
- PIPESTATUS array tracking per-command exit codes in pipelines
- Subshell (...) variable isolation (changes don't leak to parent)
- Heredoc tab-stripping with <<- syntax
- ${!prefix*} / ${!prefix@} variable name prefix matching
Parser fixes:
- HereDocStrip token for <<- heredocs
- Fix arithmetic for-loop condition reconstruction (<=, >= operators)
- PrefixMatch WordPart for ${!prefix*} expansion
https://claude.ai/code/session_012rzB3FRw7yoQWCG1mxyW7J
29312c2 to
1e40756
Compare
- set -o pipefail: pipeline returns rightmost non-zero exit code
- trap ERR: fires on non-zero exit from semicolon-separated commands
- ${var@Q/@U/@u/@L/@A/@a/@e}: parameter transformation operators
- printf -v varname: assign formatted output to variable
- read -a arr: read words into indexed array
- read -n N: read at most N characters
- read -d delim: custom delimiter
- set -o/+o long option names (pipefail, errexit, nounset, etc.)
- Fix cargo vet exemption versions for dependency bumps
- Update 009-implementation-status.md: trap partially implemented,
800 bash test cases (up from 744)
Variable assignments now check call_stack frames before writing to globals, matching bash's dynamic scoping. Also uses set_variable() in all arithmetic assignment paths (=, +=, ++, -- etc). 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
**(exponentiation) operator with correct precedence over*16#ff,2#1010,8#77) and0x/077prefix literals!,~,-) in arithmetic expressionsmapfile/readarraybuiltin with-tflag and custom array namesexpand_arithmetic_varsto track numeric literal context, preventing hex digits from being expanded as variable namesTest plan
bash_diff)cargo test --all-features)