Fix PowerShell variable assignment with subexpression operator#32
Merged
Conversation
Wrap bare `if` expression assignments in $() subexpressions for compatibility with Windows PowerShell 5.1, which doesn't support `if` as an expression on the RHS of assignments without $(). https://claude.ai/code/session_01HfYjYPU2SBFdzSxMKF5ruf
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 PowerShell variable assignments by wrapping conditional expressions in the subexpression operator
$(). This ensures proper evaluation and assignment of the conditional results to variables.Key Changes
if-elseexpressions in subexpression operator$()for$MizanMethod,$MizanDir, and$MizanBranchvariable assignments$archvariable assignment in theGet-PlatformfunctionImplementation Details
The subexpression operator
$()forces PowerShell to evaluate the entire expression and return its result before assignment. Without it, the variable assignment may not properly capture the conditional result, potentially leading to unexpected behavior or type issues. This is a best practice in PowerShell for ensuring reliable variable initialization with complex expressions.https://claude.ai/code/session_01HfYjYPU2SBFdzSxMKF5ruf