Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/System.Management.Automation/utils/PathUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,10 @@ internal static string ResolveFilePath(string filePath, PSCmdlet command, bool i
PSDriveInfo drive = null;
path =
command.SessionState.Path.GetUnresolvedProviderPathFromPSPath(
filePath, cmdletProviderContext, out provider, out drive);
isLiteralPath ? filePath : WildcardPattern.Unescape(filePath),
cmdletProviderContext,
out provider,
out drive);
cmdletProviderContext.ThrowFirstErrorOrDoNothing();
if (!provider.NameEquals(command.Context.ProviderNames.FileSystem))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Describe "Out-File" -Tags "CI" {
$expectedContent = "some test text"
$inObject = New-Object psobject -Property @{text=$expectedContent}
$testfile = Join-Path -Path $TestDrive -ChildPath outfileTest.txt
$testfileSp = Join-Path -Path $TestDrive -ChildPath "``[outfileTest``].txt"
}

AfterEach {
Expand Down Expand Up @@ -91,6 +92,14 @@ Describe "Out-File" -Tags "CI" {
$actual[11] | Should -BeNullOrEmpty
}

It "Should create the file with correct name when FilePath contains special char" {
Out-File -FilePath $testfile
Out-File -FilePath $testfileSp

$testfile | Should -Exist
$testfileSp | Should -Exist
}

It "Should limit each line to the specified number of characters when the width switch is used on objects" {

Out-File -FilePath $testfile -Width 10 -InputObject $inObject
Expand Down