Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Copy-Item does not understand symlinks #2957

Copy link
Copy link
@andyleejordan

Description

@andyleejordan
Issue body actions

Steps to reproduce

~/test |-/ mkdir folder
~/test |-/ touch file
~/test |-/ ln -s folder validfolderlink
~/test |-/ ln -s file validfilelink
~/test |-/ ln -s foobarbaz brokenlink
~/test |-/ Copy-Item ./validfolderlink validfolderlinkcopy
~/test |-/ ls -l validfolderlinkcopy
total 0
~/test |-/ Copy-Item ./validfilelink validfilelinkcopy
~/test |-/ ls -l ./validfilelinkcopy
-rw-rw-r--. 1 andschwa andschwa 0 Jan  5 13:29 ./validfilelinkcopy
~/test |-/ Copy-Item ./brokenlink brokenlinkcopy
Copy-Item : Could not find file '/home/andschwa/test/brokenlink'.
At line:1 char:1
+ Copy-Item ./brokenlink brokenlinkcopy
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Copy-Item], FileNotFoundException
    + FullyQualifiedErrorId : System.IO.FileNotFoundException,Microsoft.PowerShell.Commands.CopyItemCommand

~/test |-/

Expected behavior

  1. validfolderlinkcopy should be a copy of the symlink validfolderlink
  2. validfilelinkcopy should be a copy of the symlink validfilelink
  3. brokenlinkcopy should be a copy of the symlink brokenlink

Actual behavior

  1. validfolderlinkcopy is a copy of link's target folder
  2. validfilelinkcopy is a copy of the link's target file
  3. PowerShell throws an error when copying brokenlink to brokenlinkcopy

Environment data

> $PSVersionTable
v6.0.0-alpha.14
> uname -nro
andschwa-centos 3.10.0-514.2.2.el7.x86_64 GNU/Linux

This is similar to #804 where New-Item did not understand broken symlinks, since it was trying to follow it. The semantics on Linux of copy/move/new is to treat the symlink as a normal file, instead of following it, but PowerShell does not do this.

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-BugIssue has been identified as a bug in the productIssue has been identified as a bug in the productWG-Cmdletsgeneral cmdlet issuesgeneral cmdlet issues

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.