Skip to content

Commit

Permalink
(#2345) Do not add trailing space to arguments
Browse files Browse the repository at this point in the history
This prevents the addition of a trailing space after silent arguments in
Install-ChocolateyInstallPackage when there are no additional arguments.
  • Loading branch information
TheCakeIsNaOH committed Jan 6, 2023
1 parent d700d5c commit 3706cfa
Showing 1 changed file with 17 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,10 @@ Pro / Business supports a single, ubiquitous install directory option.
"$msiArgs $additionalInstallArgs"
}
else {
"$msiArgs $silentArgs $additionalInstallArgs"
"$msiArgs $silentArgs"
if ($additionalInstallArgs) {
" " + $additionalInstallArgs
}
}

$env:ChocolateyExitCode = Start-ChocolateyProcessAsAdmin "$msiArgs" "$($env:SystemRoot)\System32\msiexec.exe" -validExitCodes $validExitCodes -workingDirectory $workingDirectory
Expand All @@ -353,7 +356,10 @@ Pro / Business supports a single, ubiquitous install directory option.
$msiArgs = "$msiArgs $additionalInstallArgs";
}
else {
$msiArgs = "$msiArgs $silentArgs $additionalInstallArgs";
$msiArgs = "$msiArgs $silentArgs";
if ($additionalInstallArgs) {
$msiArgs += " " + $additionalInstallArgs
}
}

$env:ChocolateyExitCode = Start-ChocolateyProcessAsAdmin "$msiArgs" "$($env:SystemRoot)\System32\msiexec.exe" -validExitCodes $validExitCodes -workingDirectory $workingDirectory
Expand All @@ -365,7 +371,11 @@ Pro / Business supports a single, ubiquitous install directory option.
$env:ChocolateyExitCode = Start-ChocolateyProcessAsAdmin "$additionalInstallArgs" $fileFullPath -validExitCodes $validExitCodes -workingDirectory $workingDirectory
}
else {
$env:ChocolateyExitCode = Start-ChocolateyProcessAsAdmin "$silentArgs $additionalInstallArgs" $fileFullPath -validExitCodes $validExitCodes -workingDirectory $workingDirectory
$exeArgs = $silentArgs
if ($additionalInstallArgs) {
$exeArgs += " " + $additionalInstallArgs
}
$env:ChocolateyExitCode = Start-ChocolateyProcessAsAdmin -Statements "$exeArgs" -ExeToRun $fileFullPath -validExitCodes $validExitCodes -workingDirectory $workingDirectory
}
}

Expand All @@ -375,7 +385,10 @@ Pro / Business supports a single, ubiquitous install directory option.
$msuArgs = "`"$fileFullPath`" $additionalInstallArgs"
}
else {
$msuArgs = "`"$fileFullPath`" $silentArgs $additionalInstallArgs"
$msuArgs = "`"$fileFullPath`" $silentArgs"
if ($additionalInstallArgs) {
$msuArgs += " " + $additionalInstallArgs
}
}
$env:ChocolateyExitCode = Start-ChocolateyProcessAsAdmin "$msuArgs" "$($env:SystemRoot)\System32\wusa.exe" -validExitCodes $validExitCodes -workingDirectory $workingDirectory
}
Expand Down

0 comments on commit 3706cfa

Please sign in to comment.