fix: implement missing parameter expansion and fix output mismatches#112
Merged
fix: implement missing parameter expansion and fix output mismatches#112
Conversation
Adds proper support for printf format specifications: - Zero-padding with %05d style formats - Width specifications (%5d, %5s) - Left-alignment with %-5d - Precision for floats (%.2f) - Sign prefix with %+d Adds FormatSpec struct to parse and apply format specifications to all numeric and string format types. Adds comprehensive printf spec tests covering all format features. https://claude.ai/code/session_016yoAaoZG7vPMbs97kbXqZb
Adds support for several bash parameter expansion features:
- Substring extraction: ${var:offset} and ${var:offset:length}
- Array slicing: ${arr[@]:offset:length}
- Pattern replacement: ${var/pattern/replacement} and ${var//pattern/replacement}
- Case conversion: ${var^^}, ${var^}, ${var,,}, ${var,}
- Indirect expansion: ${!var}
Adds new AST variants:
- WordPart::Substring for variable substring extraction
- WordPart::ArraySlice for array slicing
- WordPart::IndirectExpansion for indirect variable lookup
- ParameterOp variants for replacement and case conversion
Includes comprehensive tests for all new features.
https://claude.ai/code/session_016yoAaoZG7vPMbs97kbXqZb
The regex crate interprets $1p as a named capture group "1p" instead
of capture group 1 followed by literal "p". This caused backreferences
like \1 followed by text to produce empty results.
Fixed by using ${N} format instead of $N format when converting sed
backreferences to regex replacement syntax.
Adds test for single backreference and enables the previously skipped
sed_backref_1 test.
https://claude.ai/code/session_016yoAaoZG7vPMbs97kbXqZb
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
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
This PR fixes several output mismatches between bashkit and bash, implementing missing parameter expansion features and fixing sed backreference handling.
Changes
Printf zero-padding support (
%05d,%5s, etc.)FormatSpecstruct to parse and apply format specificationsAdvanced parameter expansion features
${var:offset}and${var:offset:length}${arr[@]:offset:length}${var/pattern/replacement}and${var//pattern/replacement}${var^^},${var^},${var,,},${var,}${!var}Sed backreference fix
${N}format instead of$N$1pas named group "1p"Tests
Fixed Issues
${arr[@]:1:3}2 3 4${x:0:5}hello${x/world/bash}hello_worldhello_bash${!a}value${x^^}helloHELLO${x,,}HELLOhelloprintf "%05d" 424200042sed 's/\(hel\)lo/\1p/'helpTest plan
cargo test --package bashkit- all tests passcargo clippy- no warningscargo fmt --check- properly formattedhttps://claude.ai/code/session_016yoAaoZG7vPMbs97kbXqZb