Support Split-Path switches with LiteralPath#27517
Open
KirtiRamchandani wants to merge 3 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds support for using Split-Path “parsing switches” with -LiteralPath, and introduces tests to validate correct parameter binding and conflicts.
Changes:
- Extend
SplitPathCommandwith dedicated-LiteralPathparameter sets for-Leaf,-LeafBase,-Extension,-Qualifier,-NoQualifier, and-IsAbsolute - Add Pester coverage for
Split-Pathswitch parsing behavior when-LiteralPathis used - Add a negative test for conflicting parsing switches with
-LiteralPath
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| test/powershell/Modules/Microsoft.PowerShell.Management/Split-Path.Tests.ps1 | Adds new tests ensuring parsing switches work (and conflict) with -LiteralPath. |
| src/Microsoft.PowerShell.Commands.Management/commands/management/ParsePathCommand.cs | Adds new -LiteralPath-specific parameter sets so parsing switches bind correctly. |
Comment on lines
+102
to
+103
| $null = New-Item -ItemType Directory -Path $literalDir | ||
| $null = New-Item -ItemType File -Path $literalPath |
Comment on lines
+109
to
+110
| Split-Path -LiteralPath $literalPath -Qualifier | Should -BeExactly (Split-Path -Path $literalPath -Qualifier) | ||
| Split-Path -LiteralPath $literalPath -NoQualifier | Should -BeExactly (Split-Path -Path $literalPath -NoQualifier) |
Comment on lines
+97
to
+100
| /// <summary> | ||
| /// The parameter set name to get the noqualifier set for LiteralPath. | ||
| /// </summary> | ||
| private const string literalPathNoQualifierSet = "LiteralPathNoQualifierSet"; |
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.
PR Summary
Fixes #20705.
Split-Path -LiteralPath only had a single parameter set, so switches such as -Parent, -Leaf, -LeafBase, -Extension, -Qualifier, -NoQualifier, and -IsAbsolute could not be combined with it even though -LiteralPath should generally mirror -Path while suppressing wildcard expansion.
This adds separate literal-path parameter sets for the parsing switches so the valid combinations work, while conflicting switches remain rejected by parameter binding.
PR Context
The PowerShell cmdlets working group reviewed the issue and agreed that -LiteralPath should work with the same switches as -Path, excluding edge cases.
PR Checklist
Validation
Result: Split-Path.Tests.ps1 passed: 17 passed, 0 failed.