From 031fa93b4cf13e67f37241b151dacc70ec68e2ff Mon Sep 17 00:00:00 2001 From: "James Truher [MSFT]" Date: Wed, 20 Jul 2022 14:47:50 -0700 Subject: [PATCH] Add `find.exe` to legacy argument binding behavior for Windows (#17715) --- .../engine/NativeCommandProcessor.cs | 1 + .../NativeCommandArguments.Tests.ps1 | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/src/System.Management.Automation/engine/NativeCommandProcessor.cs b/src/System.Management.Automation/engine/NativeCommandProcessor.cs index 5ebaccca2c..0077e13d96 100644 --- a/src/System.Management.Automation/engine/NativeCommandProcessor.cs +++ b/src/System.Management.Automation/engine/NativeCommandProcessor.cs @@ -248,6 +248,7 @@ namespace System.Management.Automation "cmd", "cscript", "wscript", + "find", }; #region ctor/native command properties diff --git a/test/powershell/Language/Scripting/NativeExecution/NativeCommandArguments.Tests.ps1 b/test/powershell/Language/Scripting/NativeExecution/NativeCommandArguments.Tests.ps1 index aead692cc6..191f7211f6 100644 --- a/test/powershell/Language/Scripting/NativeExecution/NativeCommandArguments.Tests.ps1 +++ b/test/powershell/Language/Scripting/NativeExecution/NativeCommandArguments.Tests.ps1 @@ -171,6 +171,25 @@ Describe "Will error correctly if an attempt to set variable to improper value" } } +Describe "find.exe uses legacy behavior on Windows" { + BeforeAll { + $currentSetting = $PSNativeCommandArgumentPassing + $PSNativeCommandArgumentPassing = "Windows" + $testCases = @{ pattern = "" }, + @{ pattern = "blat" }, + @{ pattern = "bl at" } + } + AfterAll { + $PSNativeCommandArgumentPassing = $currentSetting + } + It "The pattern '' is used properly by find.exe" -skip:(! $IsWindows) -testCases $testCases { + param ($pattern) + $expr = "'foo' | find.exe --% /v ""$pattern""" + $result = Invoke-Expression $expr + $result | Should -Be 'foo' + } +} + foreach ( $argumentListValue in "Standard","Legacy","Windows" ) { $PSNativeCommandArgumentPassing = $argumentListValue Describe "Native Command Arguments (${PSNativeCommandArgumentPassing})" -tags "CI" {