Skip to content

Commit

Permalink
Except for NSIS' '/D' arg
Browse files Browse the repository at this point in the history
  • Loading branch information
niheaven committed Mar 24, 2024
1 parent 326ee8f commit f8db2bd
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions lib/core.ps1
Expand Up @@ -600,8 +600,7 @@ function Invoke-ExternalCommand {
[CmdletBinding(DefaultParameterSetName = "Default")]
[OutputType([Boolean])]
param (
[Parameter(Mandatory = $true,
Position = 0)]
[Parameter(Mandatory = $true, Position = 0)]
[Alias("Path")]
[ValidateNotNullOrEmpty()]
[String]
Expand Down Expand Up @@ -664,9 +663,9 @@ function Invoke-ExternalCommand {
$escapedArgs = $ArgumentList | ForEach-Object {
# escape N consecutive backslash(es), which are followed by a double quote or at the end of the string, to 2N consecutive ones
$s = $_ -replace '(\\+)(""|$)', '$1$1$2'
# quote the path if it contains spaces
if ($s -match ' ') {
$s = $s -replace '([A-Za-z]:[\\/].*)', '`"$1`"'
# quote the path if it contains spaces and is not NSIS's '/D' argument
if ($s -match ' ' -and $s -notmatch '/D=[A-Z]:[\\/].*') {
$s = $s -replace '([A-Z]:[\\/].*)', '`"$1`"'
} else {
$s
}
Expand Down

0 comments on commit f8db2bd

Please sign in to comment.