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
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,13 @@ private Collection<PathInfo> ResolveDriveQualifiedPath(

s_pathResolutionTracer.WriteLine("Path is DRIVE-QUALIFIED");

string relativePath = GetDriveRootRelativePathFromPSPath(path, context, true, out drive, out providerInstance);
string relativePath =
GetDriveRootRelativePathFromPSPath(
path,
context,
!context.SuppressWildcardExpansion,
out drive,
out providerInstance);

Dbg.Diagnostics.Assert(
drive != null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
# Licensed under the MIT License.
Describe "Move-Item tests" -Tag "CI" {
BeforeAll {
$content = "This is content"
Setup -f originalfile.txt -content "This is content"
$source = "$TESTDRIVE/originalfile.txt"
$target = "$TESTDRIVE/ItemWhichHasBeenMoved.txt"
Setup -f [orig-file].txt -content "This is not content"
$sourceSp = "$TestDrive/``[orig-file``].txt"
$targetSpName = "$TestDrive/ItemWhichHasBeen[Moved].txt"
$targetSp = "$TestDrive/ItemWhichHasBeen``[Moved``].txt"
Setup -Dir [test-dir]
$wdSp = "$TestDrive/``[test-dir``]"
}
It "Move-Item will move a file" {
Move-Item $source $target
Expand All @@ -23,6 +24,36 @@ Describe "Move-Item tests" -Tag "CI" {
$targetSp | Should -Exist
$targetSp | Should -FileContentMatchExactly "This is not content"
}
It "Move-Item will move a file when -Path and CWD contains special char" {
$content = "This is content"
$oldSpName = "[orig]file.txt"
$oldSpBName = "``[orig``]file.txt"
$oldSp = "$wdSp/$oldSpBName"
$newSpName = "[moved]file.txt"
$newSp = "$wdSp/``[moved``]file.txt"
In $wdSp -Execute {
$null = New-Item -Name $oldSpName -ItemType File -Value $content -Force
Move-Item -Path $oldSpBName $newSpName
}
$oldSp | Should -Not -Exist
$newSp | Should -Exist
$newSp | Should -FileContentMatchExactly $content
}
It "Move-Item will move a file when -LiteralPath and CWD contains special char" {
$content = "This is not content"
$oldSpName = "[orig]file2.txt"
$oldSpBName = "``[orig``]file2.txt"
$oldSp = "$wdSp/$oldSpBName"
$newSpName = "[moved]file2.txt"
$newSp = "$wdSp/``[moved``]file2.txt"
In $wdSp -Execute {
$null = New-Item -Name $oldSpName -ItemType File -Value $content -Force
Move-Item -LiteralPath $oldSpName $newSpName
}
$oldSp | Should -Not -Exist
$newSp | Should -Exist
$newSp | Should -FileContentMatchExactly $content
}

Context "Move-Item with filters" {
BeforeAll {
Expand Down