Repository navigation
fix(interpreter): special params $0, $-, BASH_SUBSHELL, positional slices - #2586
Merged
Merged
Conversation
…ices
- $0 keeps script name inside functions and sourced files
- $- reports active short options (h and B always on)
- BASH_SUBSHELL tracks subshell / cmd-subst / pipeline-stage depth
- ${@:off[:len]} and ${*:off} slice positional params
- ${#}, ${-...}, ${?...}, ${$...} parse as special params
- read -a keeps empty fields between delimiters
Claude-Session: https://claude.ai/code/session_019aFikmptPc91Fj4N2iDXQA
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
bashkit | 25b5e67 | Commit Preview URL Branch Preview URL |
Oct 07 2026, 06:44 PM |
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.
Requested by Михайло · project thread
What changed
Special parameters now behave like bash:
$0keeps the script name inside functions and sourced files.$-lists the active short options (handBalways on).$BASH_SUBSHELLtracks the depth of( ),$( )and compound pipeline stages.${@:off[:len]}/${*:off}slice positional parameters, with$0at offset 0.${#}and${-…},${?…},${$…}with operators now parse.read -akeeps empty fields between delimiters.Why
These are level-up roadmap step 1 fidelity gaps from the Debian-oracle shell cases. Scripts use
$0for usage messages,case $- in *i*)for interactivity checks, and"${@:2}"for argument forwarding.Before / After
f(){ echo $0; }; ffecho "${-//c/}"hBecho $BASH_SUBSHELL $(echo $BASH_SUBSHELL) $( (echo $BASH_SUBSHELL) )0 1 2set -- a b c d; echo ${@:1}b ca b c dset -- a b c d; echo ${#}04IFS=, read -ra p <<< a,b,,d; echo ${#p[@]}34Proof: new spec
special-vars-subshell.test.sh(bash-verified),bash_comparisonpasses.Risk
Low.
$-now reportshB, and one security test was updated for that.BASH_SUBSHELLis a counter that is saved and restored with the subshell snapshot.Checklist
cargo test -p bashkit --lib/--test integration/bash_comparison-D warnings, fmthttps://claude.ai/code/session_019aFikmptPc91Fj4N2iDXQA
Generated by Claude Code