@@ -769,8 +769,7 @@ await this.ExecuteCommand<object>(
769
769
/// <returns>A Task that can be awaited for completion.</returns>
770
770
public async Task ExecuteScriptWithArgs ( string script , string arguments = null , bool writeInputToHost = false )
771
771
{
772
- string reportedScript = script ;
773
- string escapedScriptPath = PowerShellContext . WildcardEscapePath ( script ) ;
772
+ var escapedScriptPath = new StringBuilder ( PowerShellContext . WildcardEscapePath ( script ) ) ;
774
773
PSCommand command = new PSCommand ( ) ;
775
774
776
775
if ( arguments != null )
@@ -798,16 +797,18 @@ public async Task ExecuteScriptWithArgs(string script, string arguments = null,
798
797
if ( File . Exists ( script ) || File . Exists ( scriptAbsPath ) )
799
798
{
800
799
// Dot-source the launched script path
801
- escapedScriptPath = ". " + QuoteEscapeString ( escapedScriptPath ) ;
800
+ string escapedFilePath = escapedScriptPath . ToString ( ) ;
801
+ escapedScriptPath = new StringBuilder ( ". " ) . Append ( QuoteEscapeString ( escapedFilePath ) ) ;
802
802
}
803
803
804
- reportedScript += " " + arguments ;
805
- escapedScriptPath = escapedScriptPath + " " + arguments ;
806
- command . AddScript ( escapedScriptPath , false ) ;
804
+ // Add arguments
805
+ escapedScriptPath . Append ( ' ' ) . Append ( arguments ) ;
806
+
807
+ command . AddScript ( escapedScriptPath . ToString ( ) , false ) ;
807
808
}
808
809
else
809
810
{
810
- command . AddCommand ( escapedScriptPath , false ) ;
811
+ command . AddCommand ( escapedScriptPath . ToString ( ) , false ) ;
811
812
}
812
813
813
814
if ( writeInputToHost )
0 commit comments