mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Resolve the working directory as literal path for Start-Process when it's not specified (#11946)
This commit is contained in:
@@ -1896,7 +1896,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
else
|
||||
{
|
||||
// Working Directory not specified -> Assign Current Path.
|
||||
startInfo.WorkingDirectory = ResolveFilePath(this.SessionState.Path.CurrentFileSystemLocation.Path);
|
||||
startInfo.WorkingDirectory = PathUtils.ResolveFilePath(this.SessionState.Path.CurrentFileSystemLocation.Path, this, isLiteralPath: true);
|
||||
}
|
||||
|
||||
if (this.ParameterSetName.Equals("Default"))
|
||||
|
||||
@@ -15,6 +15,8 @@ Describe "Start-Process" -Tag "Feature","RequireAdminOnWindows" {
|
||||
$pingCommand = (Get-Command -CommandType Application ping)[0].Definition
|
||||
$pingDirectory = Split-Path $pingCommand -Parent
|
||||
$tempFile = Join-Path -Path $TestDrive -ChildPath PSTest
|
||||
$tempDirectory = Join-Path -Path $TestDrive -ChildPath 'PSPath[]'
|
||||
New-Item $tempDirectory -ItemType Directory -Force
|
||||
$assetsFile = Join-Path -Path (Join-Path -Path $PSScriptRoot -ChildPath assets) -ChildPath SortTest.txt
|
||||
if ($IsWindows) {
|
||||
$pingParam = "-n 2 localhost"
|
||||
@@ -69,6 +71,15 @@ Describe "Start-Process" -Tag "Feature","RequireAdminOnWindows" {
|
||||
$process.Id | Should -BeGreaterThan 1
|
||||
# $process.ProcessName | Should -Be "ping"
|
||||
}
|
||||
|
||||
It "Should work correctly within an unspecified WorkingDirectory with wildcard-type characters" {
|
||||
Push-Location -LiteralPath $tempDirectory
|
||||
$process = Start-Process ping -ArgumentList $pingParam -PassThru -RedirectStandardOutput "$TESTDRIVE/output" @extraArgs
|
||||
$process.Length | Should -Be 1
|
||||
$process.Id | Should -BeGreaterThan 1
|
||||
# $process.ProcessName | Should -Be "ping"
|
||||
Pop-Location
|
||||
}
|
||||
|
||||
It "Should handle stderr redirection without error" {
|
||||
$process = Start-Process ping -ArgumentList $pingParam -PassThru -RedirectStandardError $tempFile -RedirectStandardOutput "$TESTDRIVE/output" @extraArgs
|
||||
|
||||
Reference in New Issue
Block a user