Repository navigation
shell: reintroduce shell variants - #759
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 045e4c8f5d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4becfcd202
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| cfg.NewPipe = exec.NewPipe | ||
| cfg.LegacyBashCompat = exec.Interpreter == "bash" || exec.Interpreter == "sh" | ||
| cfg.ShellVariant = executionShellVariant(exec) | ||
| cfg.LegacyBashCompat = path.Base(strings.TrimSpace(exec.Interpreter)) == "bash" |
There was a problem hiding this comment.
Derive legacy-compat mode from resolved shell variant
runnerConfig still enables LegacyBashCompat from Interpreter instead of the already-resolved shell variant, so requests that intentionally override parser behavior (for example Interpreter="bash" with ShellVariant="sh") still inherit Bash-legacy behavior. That leaks interpreter metadata back into runtime semantics (not just argv0/presentation), which can change observable behavior such as POSIX-mode shift diagnostics and [[ =~ ]] parse diagnostics even when the caller explicitly selected a non-Bash variant.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ca83d13cd1
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| func (v Variable) ResolveRefState(env Environ, ref *syntax.VarRef) (RefResolution, error) { | ||
| return v.ResolveRefStateVariant(env, ref, syntax.LangBash) | ||
| } |
There was a problem hiding this comment.
Use active variant for default nameref resolution
ResolveRefState now hard-codes syntax.LangBash, while runner paths still call Variable.ResolveRef for nameref traversal in non-Bash variants. In ShellVariant=sh, this lets nameref targets be reparsed with Bash rules (for example array-style targets) and can bypass the new POSIX varref restrictions added elsewhere. Please route runner nameref resolution through the variant-aware path so SH mode cannot resolve references that only parse in Bash.
Useful? React with 👍 / 👎.
Summary
ShellVariantplumbing across public/internal requests andsession.execsh,mksh, andzshexecution paths, rejectbatsrunner features explicitly, and updateSPEC.mdWhy
We removed the upstream
mvdan/shshell-specific support during the port, which left the runtime effectively Bash-only and hard-coded Bash behavior into several parser and interpreter helper paths. This change makes shell variant selection first-class again without pretending thatbatshas a full harness implementation.Impact
shell_variantdirectly on execution and interactive requestsshnow starts in POSIX mode with brace expansion disabledmkshandzshselect their syntax variants while keeping the current non-POSIX runtime defaultsbatsparses as a dialect but@testexecution and#!/bin/batsdispatch fail with an explicit runner-not-implemented errorValidation
make testmake lint