Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/pwsh-install-template.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Comment thread
caomengxuan666 marked this conversation as resolved.
if ($source -match '^-[^-][^\s]*\.[^\s]*$' -and
$source.IndexOfAny([char[]]@('*', '?', '[', ']')) -lt 0) {
$rewrittenArgs += "'" + ((__coreutils_q $source).Replace("'", "''")) + "'"
$i++
continue
}
$rewrittenArgs += $source
$i++
continue
Expand Down