Skip to content

Commit

Permalink
Change variable name
Browse files Browse the repository at this point in the history
to be more representative of what we're working with. Tighten up what will activate the Legacy behavior by including the directory separator for the executables.
  • Loading branch information
JamesWTruher committed Jun 1, 2021
1 parent 6c688cd commit fc7da11
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions src/System.Management.Automation/engine/NativeCommandProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1267,25 +1267,30 @@ private ProcessStartInfo GetProcessStartInfo(bool redirectOutput, bool redirectE
/// Determine if we have a special file which will change the way native argument passing
/// is done on Windows. We use legacy behavior for cmd.exe, .bat, .cmd files.
/// </summary>
/// <param name="filename">The file to use when checking how to pass arguments.</param>
/// <param name="filePath">The file to use when checking how to pass arguments.</param>
/// <returns>A boolean indicating what passing style should be used.</returns>
private static bool UseLegacyPassingStyle(string filename)
private static bool UseLegacyPassingStyle(string filePath)
{
if (filename == null || filename == string.Empty)
if (filePath == null || filePath == string.Empty)
{
return false;
}

string commandPath = filename.ToLowerInvariant();
string commandPath = filePath.ToLowerInvariant();

// This is the list of files which will trigger Legacy behavior if
// PSNativeCommandArgumentPassing is set to "Windows".
// The following native commands have non-standard behavior with regard to argument passing.
// It's possible (but not likely) that one of the executables could have forward slashes,
// so we check for both.
string[] exceptions = new string[]
{
"cmd.exe",
"cscript.exe",
"wscript.exe",
"\\cmd.exe",
"/cmd.exe",
"\\cscript.exe",
"/cscript.exe",
"\\wscript.exe",
"/wscript.exe",
".bat",
".cmd",
".vbs",
Expand All @@ -1294,7 +1299,7 @@ private static bool UseLegacyPassingStyle(string filename)
};
foreach (string exception in exceptions)
{
if (filename.EndsWith(exception))
if (filePath.EndsWith(exception))
{
return true;
}
Expand Down

0 comments on commit fc7da11

Please sign in to comment.