Fix the alternate path separator for Linux

Because normalization of paths occurs through the location globber and
filesystem provider by way of `path.Replace(alternate, default)`,
changing the alternate path separator on Linux to be '\' instead of
.NET's '/' let's PowerShell be "slash agnostic."
This commit is contained in:
Andrew Schwartzmeyer 2016-06-08 10:49:01 -07:00
parent 140cb4aece
commit a8f93c3c64

View File

@ -26,6 +26,9 @@ namespace System.Management.Automation
/// <summary>
/// The default path separator used by the base implementation of the providers.
///
/// Porting note: IO.Path.DirectorySeparatorChar is correct for all platforms. On Windows,
/// it is '\', and on Linux, it is '/', as expected.
/// </summary>
///
internal static readonly char DefaultPathSeparator = System.IO.Path.DirectorySeparatorChar;
@ -33,9 +36,14 @@ namespace System.Management.Automation
/// <summary>
/// The alternate path separator used by the base implementation of the providers.
///
/// Porting note: we do not use .NET's AlternatePathSeparatorChar here because it correctly
/// states that both the default and alternate are '/' on Linux. However, for PowerShell to
/// be "slash agnostic", we need to use the assumption that a '\' is the alternate path
/// separator on Linux.
/// </summary>
///
internal static readonly char AlternatePathSeparator = System.IO.Path.AltDirectorySeparatorChar;
internal static readonly char AlternatePathSeparator = Platform.IsWindows ? '/' : '\\';
internal static readonly string AlternatePathSeparatorString = AlternatePathSeparator.ToString();
/// <summary>