fix: detect Git Bash/WSL/MSYS2 shell on Windows (non-interactive-env hook)#3370
Open
Zireael wants to merge 1 commit intocode-yeongyu:devfrom
Open
fix: detect Git Bash/WSL/MSYS2 shell on Windows (non-interactive-env hook)#3370Zireael wants to merge 1 commit intocode-yeongyu:devfrom
Zireael wants to merge 1 commit intocode-yeongyu:devfrom
Conversation
Contributor
|
All contributors have signed the CLA. Thank you! ✅ |
Author
|
I have read the CLA Document and I hereby sign the CLA |
There was a problem hiding this comment.
2 issues found across 1 file
Confidence score: 3/5
- There is a concrete user-impacting risk in
src/shared/shell-env.ts: usingTERMas a broad Unix-shell signal can misclassify Windows PowerShell sessions and produce invalid env-prefix syntax. - Both findings are medium severity (6/10) with high confidence (8/10), so this looks like a real behavior regression risk rather than a minor style issue.
- Pay close attention to
src/shared/shell-env.ts- shell detection order/guards should avoidTERMpreempting PowerShell logic, especially across Windows vs non-Windows environments.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="src/shared/shell-env.ts">
<violation number="1" location="src/shared/shell-env.ts:27">
P2: Scope the Unix-indicator override to Windows; otherwise it can preempt the PowerShell detection on non-Windows environments when `TERM` is set.</violation>
<violation number="2" location="src/shared/shell-env.ts:28">
P2: TERM is too broad a Unix-shell indicator here; on Windows PowerShell sessions where TERM is set, this branch misclassifies the shell as unix and generates invalid env-prefix syntax.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
There was a problem hiding this comment.
0 issues found across 1 file (changes from recent commits).
Auto-approved: Fixes incorrect PowerShell detection for Git Bash/WSL/MSYS2 on Windows. Safe as markers used are specific to Unix-like environments and the previous logic already defaulted to PowerShell.
23b1014 to
71adad1
Compare
Author
|
recheck |
On Windows, PSModulePath is always set by the system even when the active shell is Git Bash, WSL, or MSYS2. detectShellType() returned 'powershell' in these cases, causing the non-interactive-env hook to prepend PowerShell $env: syntax which Git Bash cannot parse. Adds checks for TERM, BASH_VERSION, MSYSTEM, and WSL_DISTRO_NAME before the PSModulePath check to correctly identify Unix shells. Fixes code-yeongyu#3366
71adad1 to
998dbde
Compare
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
detectShellType()generating PowerShell:syntax when the active shell is Git Bash, WSL, or MSYS2 on WindowsTERM,BASH_VERSION,MSYSTEM,WSL_DISTRO_NAME) before thePSModulePathcheck, which is always set on Windows regardless of the active shellProblem
On Windows,
PSModulePathis always set by the system — even when the active shell is Git Bash. The previous logic checkedPSModulePathbefore any Unix indicators, causing thenon-interactive-envhook to prepend PowerShell:VAR='value';syntax to every bash command. Git Bash interprets these as 15 separatecommand not founderrors per invocation.Root Cause
src/shared/shell-env.tsline 24:detectShellType()returned"powershell"on Windows becausePSModulePathcheck preceded any Unix shell detection.Fix
Inserted a check for Unix-compatible shell env vars between the
SHELLandPSModulePathchecks:This ensures Git Bash users get
export VAR=value;(Unix syntax) instead of:VAR='value';(PowerShell syntax).Fixes #3366
Summary by cubic
Fixes shell detection on Windows so Git Bash, WSL, and MSYS2 are treated as Unix shells. The
non-interactive-envhook now uses Unix export syntax and avoids bash errors.PSModulePath:BASH_VERSION,MSYSTEM,WSL_DISTRO_NAME(excludeTERMto avoid PowerShell false positives).detectShellType()now returns "unix" for Git Bash/WSL/MSYS2, preventing PowerShell-style prefixes innon-interactive-env.Written for commit 998dbde. Summary will update on new commits.