mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Fix the pref regression to the '-replace' operator after adding ScriptBlock support (#7135)
This commit is contained in:
committed by
Dongbo Wang
parent
13e925e13e
commit
bacda46941
@@ -908,7 +908,7 @@ namespace System.Management.Automation
|
||||
pattern = rList[0];
|
||||
if (rList.Count > 1)
|
||||
{
|
||||
substitute = rList[1];
|
||||
substitute = PSObject.Base(rList[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -972,6 +972,9 @@ namespace System.Management.Automation
|
||||
{
|
||||
switch (substitute)
|
||||
{
|
||||
case string replacementString:
|
||||
return regex.Replace(input, replacementString);
|
||||
|
||||
case ScriptBlock sb:
|
||||
MatchEvaluator me = match => {
|
||||
var result = sb.DoInvokeReturnAsIs(
|
||||
|
||||
Reference in New Issue
Block a user