fix(system): $dir parameter passing to Split-PathLikeEnvVar at strip_path with -Pattern switch
#5937
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.
Description
Correct parameter's name,
-Nameto-Pattern. Corresponds to the new parameter name -Pattern for theSplit-PathLikeEnvVarfunction.Motivation and Context
Function
Test-PathLikeEnvVaris changed toSplit-PathLikeEnvVarrecently, which also updated to provide-Patternparameter with string array type to the function. Butstrip_path, which is now deprecated function and implemented to invoke warning andSplit-PathLikeEnvVarfunction with$dirand$orig_pathparameters, is still passing$dirparameter as-Nameto the newer function. So$Patternhas$nullvalue and causes null-valued expression error.As we can see, the function could not receive the value to
$Patterncorrectly.The error was that:
I discovered this issue when I invoked
scoop update *to try to update SDL2, null-valued expression errors were occurred.I fixed
split_pathfunction to pass the parameter as-Patterncorrectly. Moreover, add casting related code, that's becauseSplit-PathLikeEnvVarrequires$Patternas a string array, not a single string, It would be better to explicitly change$dirto an array.I believe that we can troubleshoot this problem by updating
strip_pathfunction for now, we should also update manifests not to use deprecated functions like this ultimately.Before:
After:
How Has This Been Tested?
Tested on both Windows 10 (22H2) and Windows 11(23H2)
Checklist:
developbranch.