From c1789cd0ef2f675cf096d87adf57fd34e95fa5d3 Mon Sep 17 00:00:00 2001 From: caomengxuan666 <2507560089@qq.com> Date: Wed, 3 Jun 2026 14:09:26 +0800 Subject: [PATCH] Quote dash-prefixed path arguments in pwsh wrapper --- src/pwsh-install-template.ps1 | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/pwsh-install-template.ps1 b/src/pwsh-install-template.ps1 index 19ec19b..0d80268 100644 --- a/src/pwsh-install-template.ps1 +++ b/src/pwsh-install-template.ps1 @@ -169,6 +169,16 @@ function PSConsoleHostReadLine { $argsStart = $wordEnd # IndexOfAny beats running the regex per arg. if ($source.IndexOfAny($script:__COREUTILS_ARG_SPECIAL__) -lt 0) { + # PowerShell's Legacy native argument mode can split extension-like + # parameter tokens (e.g. -dash.txt -> -dash + .txt) for .cmd + # targets. Quote these tokens while leaving ordinary bare globs + # unquoted so coreutils can still expand them. + if ($source -match '^-[^-][^\s]*\.[^\s]*$' -and + $source.IndexOfAny([char[]]@('*', '?', '[', ']')) -lt 0) { + $rewrittenArgs += "'" + ((__coreutils_q $source).Replace("'", "''")) + "'" + $i++ + continue + } $rewrittenArgs += $source $i++ continue