-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Description
Part of the resolution of issue #621 was to have the -Recurse option be ignored when removing a symlink to a directory with a command such as Remove-Item -Recurse -Path linktodir, to be more in line with the unix Unix rm command.
However, on Unix the rm command, when given as rm -r linktodir/', with the trailing slash on the pathname, *will* recurse into the target directory and delete its contents, then remove the link, leaving the target directory behind. Without the trailing slash rm -r linktodir` simply removes the link.
Steps to reproduce
New-Item -ItemType Directory subdir
New-Item subdir/file.txt
New-Item -ItemType SymbolicLink link-to-sub -value subdir
Remove-Item -Recurse link-to-sub/Expected behavior
Symbolic link link-to-sub should be deleted, directory subdir should still exist but be empty.
Actual behavior
On Linux, the directory subdir is emptied and remains, but an error is emitted and the symbolic link is not deleted. Error is Not a directory.
On Windows, the symbolic link is deleted but the directory subdir and its contents remain.
Environment data
> $PSVersionTable
Name Value
---- -----
BuildVersion 3.0.0.0
CLRVersion
GitCommitId v6.0.0-alpha.18-33-ged4e77d65809ed8ee2589fd50...
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
PSEdition Core
PSRemotingProtocolVersion 2.3
PSVersion 6.0.0-alpha
SerializationVersion 1.1.0.1
WSManStackVersion 3.0