Skip to content
Merged
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 @@ -3535,7 +3535,12 @@ internal void NewItem(
throw PSTraceSource.NewInvalidOperationException(SessionStateStrings.PathNotFound, targetPath);
}

content = globbedTarget[0];
// If the original target was a relative path, we want to leave it as relative if it did not require
// globbing to resolve.
if (WildcardPattern.ContainsWildcardCharacters(targetPath))
{
content = globbedTarget[0];
}
}

NewItemPrivate(providerInstance, composedPath, type, content, context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,6 @@ Describe "Hard link and symbolic link tests" -Tags "CI", "RequireAdminOnWindows"

Context "Get-ChildItem and symbolic links" {
BeforeAll {
$TestDrive = "TestDrive:"
$alphaDir = Join-Path $TestDrive "sub-alpha"
$alphaLink = Join-Path $TestDrive "link-alpha"
$alphaFile1 = Join-Path $alphaDir "AlphaFile1.txt"
Expand Down Expand Up @@ -671,7 +670,6 @@ Describe "Copy-Item can avoid copying an item onto itself" -Tags "CI", "RequireA
# attempt is made to copy an item onto itself.
$selfCopyKey = "SelfCopy"

$TestDrive = "TestDrive:"
$subDir = "$TestDrive/sub"
$otherSubDir = "$TestDrive/other-sub"
$fileName = "file.txt"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,18 @@ Describe "New-Item with links" -Tags @('CI', 'RequireAdminOnWindows') {
$symbolicLinkPath = New-Item -ItemType SymbolicLink -Path "$tmpDirectory/$folderName/" -Value "/bar/"
$symbolicLinkPath | Should -Not -BeNullOrEmpty
}

It "New-Item -ItemType SymbolicLink should be able to create a relative link" -Skip:(!$IsWindows) {
try {
Push-Location $TestDrive
$relativeFilePath = Join-Path -Path . -ChildPath "relativefile.txt"
$file = New-Item -ItemType File -Path $relativeFilePath
$link = New-Item -ItemType SymbolicLink -Path ./link -Target $relativeFilePath
$link.Target | Should -BeExactly $relativeFilePath
} finally {
Pop-Location
}
}
}

Describe "New-Item with links fails for non elevated user if developer mode not enabled on Windows." -Tags "CI" {
Expand Down