Replace inference of shell with explicit parameter detection#36
Open
davidjxwu wants to merge 1 commit intopyenv-win:mainfrom
Open
Replace inference of shell with explicit parameter detection#36davidjxwu wants to merge 1 commit intopyenv-win:mainfrom
davidjxwu wants to merge 1 commit intopyenv-win:mainfrom
Conversation
Reviewer's Guide by SourceryThis pull request replaces the inference of the shell type with an explicit parameter, which is set to true when the script is called from a .bat file. This ensures that the correct shell is used when activating a virtual environment. Sequence diagram for shell detection flow before and after changessequenceDiagram
participant User
participant bat as pyenv-win-venv.bat
participant ps1 as pyenv-win-venv.ps1
rect rgb(200, 200, 200)
Note right of User: Before Changes
alt Called from CMD
User->>bat: Execute script
bat->>ps1: Execute with CommandType=ExternalScript
ps1->>ps1: Infer shell as 'bat'
else Called from PowerShell
User->>ps1: Execute directly
ps1->>ps1: Infer shell as 'ps1'
end
end
rect rgb(200, 255, 200)
Note right of User: After Changes
alt Called from CMD
User->>bat: Execute script
bat->>ps1: Execute with CalledFromCMD=true
ps1->>ps1: Set shell as 'bat'
else Called from PowerShell
User->>ps1: Execute directly
ps1->>ps1: Set shell as 'ps1'
end
end
Flow diagram for shell detection logic changesflowchart TD
A[Start] --> B{CalledFromCMD?}
B -->|Yes| C[Set shell = 'bat']
B -->|No| D[Set shell = 'ps1']
C --> E[Continue script execution]
D --> E
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey @davidjxwu - I've reviewed your changes - here's some feedback:
Overall Comments:
- The .bat file needs to be updated to pass the new -CalledFromCMD parameter when invoking the PowerShell script, otherwise the shell detection won't work correctly.
Here's what I looked at during the review
- 🟢 General issues: all looks good
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
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.
When calling pyenv-win-venv using the pyenv-venv invocation, the CommandType is mapped to an "ExternalScript", which then makes the activation of a virtualenv create a CMD shell, even if initially called from powershell.
This removes that inference in favour of an explicit call parameter which is set to True only when the .bat file is called, which should (only) be whenever pyenv-win-venv is invoked from a CMD shell.
Summary by Sourcery
Bug Fixes: