Skip to content

Allow creation of symlink to non-existent target - #804

Merged
Andy Jordan (andyleejordan) merged 1 commit into
masterfrom
andschwa/symbolic-target
Apr 10, 2016
Merged

Allow creation of symlink to non-existent target#804
Andy Jordan (andyleejordan) merged 1 commit into
masterfrom
andschwa/symbolic-target

Conversation

@andyleejordan

Copy link
Copy Markdown
Member

This action is completely valid on both Windows and Linux (and OS X)
operating systems; tested with mklink and ln -s respectively.

Note that targets for hard links must exist, thus we check specifically
for symbolic links.

Both the path globber in session state and the New-Item implementation
needed to be fixed to allow the target not to exist.

Resolves #801.


This change is Reviewable

This action is completely valid on both Windows and Linux (and OS X)
operating systems; tested with `mklink` and `ln -s` respectively.

Note that targets for hard links must exist, thus we check specifically
for symbolic links.

Both the path globber in session state and the `New-Item` implementation
needed to be fixed to allow the target not to exist.

Resolves #801.

Also enable symbolic link tests on Windows.
@andyleejordan

Copy link
Copy Markdown
Member Author

FYI Lee Holmes (@LeeHolmes)

@andyleejordan

Copy link
Copy Markdown
Member Author

Merging because I need this to make packages.

@vors

Copy link
Copy Markdown
Collaborator

Review status: 0 of 3 files reviewed at latest revision, 3 unresolved discussions.


test/powershell/New-Item.Tests.ps1, line 119 [r1] (raw file):
Please add a symlink test for a directory.

  1. Create non-existing
  2. Test ls on it
  3. Create matching dir
  4. Test ls again

test/powershell/New-Item.Tests.ps1, line 122 [r1] (raw file):
not sure that this is the right behavior


test/powershell/New-Item.Tests.ps1, line 128 [r1] (raw file):
How does somebody can figure out that this symlink is broken?


Comments from Reviewable

@andyleejordan

Copy link
Copy Markdown
Member Author

Review status: 0 of 3 files reviewed at latest revision, 3 unresolved discussions.


test/powershell/New-Item.Tests.ps1, line 119 [r1] (raw file):
Yeah that would be good to have. I'll add it to the backlog.


test/powershell/New-Item.Tests.ps1, line 122 [r1] (raw file):
This is the right behavior; the link file exists. If it didn't, this PR would be wrong.


test/powershell/New-Item.Tests.ps1, line 128 [r1] (raw file):
By testing the existence of its Target, as done here.


Comments from Reviewable

Thatgfsj (Thatgfsj) pushed a commit to Thatgfsj/PowerShell that referenced this pull request Aug 6, 2026
…arget

Allow creation of symlink to non-existent target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix creation of symbolic links to non-existing files

2 participants