Repository navigation
Support Split-Path switches with LiteralPath - #27517
Kirtikumar Anandrao Ramchandani (KirtiRamchandani) wants to merge 3 commits into
Conversation
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. |
|
Thanks for the review. I'll update the test setup to use |
|
This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days. |
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.