fix(powershell): nested Join-Path for Windows PowerShell 5.1 compat#19
Merged
Conversation
The 3-arg Join-Path form (-AdditionalChildPath) is PS 7+ only. Windows PowerShell 5.1 (powershell.exe) rejected the third '..' with PositionalParameterNotFound, aborting Validate-FundsXml.ps1 at line 39 before any validation ran. Nested Join-Path works in both 5.1 and 7+, honoring the script's stated 5.1 compatibility. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Problem
Running
powershell -File XSD_Validation/powershell/Validate-FundsXml.ps1on Windows PowerShell 5.1 (
powershell.exe) aborted at line 39 with:The script died before any parameter binding or validation ran.
Root cause
Join-Path $PSScriptRoot '..' '..'uses the 3-argument form(
-AdditionalChildPath), which is PowerShell 7+ only. WindowsPowerShell 5.1's
Join-Pathaccepts only-Path/-ChildPath, so thethird
'..'had no positional parameter to bind to. This contradictedthe script's own docstring claim of "Works in Windows PowerShell 5.1 and
PowerShell 7+".
Fix
Use nested
Join-Path, which behaves identically in 5.1 and 7+:Verified this was the only 3-arg
Join-Pathoccurrence in the repo's.ps1files.🤖 Generated with Claude Code