Skip to content

File mode in Linux should reflect Linux modes #1817

Closed

Description

Steps to reproduce

In any Linux installation run a dir command.

Expected behavior

I would expect the same mode ouput you would get running ls -al

Actual behavior

Mode property is all ---------

Environment data

pslinux-mode

Activity

  1. fabiendibot commented on Aug 15, 2016

    @fabiendibot

    +1 and same goes for Get-Item(property)

  2. andyleejordan commented on Aug 17, 2016

    @andyleejordan
    Member

    This is currently a limitation of .NET Core (or really, a design decision due to .NET being originally created for Windows).

    > [IO.FileInfo]::new("README.md").Attributes
    Normal

    PowerShell file objects are based on the C# classes, and the C# FileInfo class uses their FileAttributes enum, which in PowerShell corresponds to the mode property.

    So, while on Linux, we'd expect a "read-only" file to display -r--r--r--, in C#, we get:

    > chmod a-w README.md
    > [IO.FileInfo]::new("README.md").Attributes
    ReadOnly

    And in PowerShell parlance:

    > Get-Item ./README.md
    
    
        Directory: /PowerShell
    
    
    Mode                LastWriteTime         Length Name
    ----                -------------         ------ ----
    --r---          8/16/16   2:51 PM           5231 README.md

    Whether or not PowerShell should ignore the C# object and instead "do its own thing" to get Linux-like file modes is a reasonable question, but would require a design change.

  3. added
    Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get a
    on Aug 17, 2016
  4. purplexa commented on Aug 18, 2016

    @purplexa

    Is there a reasonable way to have an additional PosixMode attribute or something for file objects on POSIX file systems?

  5. added this to the milestone on Sep 29, 2016
  6. SteveL-MSFT commented on Sep 29, 2016

    @SteveL-MSFT
    Member

    We should try to have a consistent experience for Linux Bash users. See if we can add custom formatting for Linux to enable this.

  7. modified the milestones: , on Dec 19, 2016
  8. modified the milestones: , 6.0.0-beta1 on Mar 18, 2017
  9. DHowett-MSFT commented on Mar 16, 2018

    @DHowett-MSFT

    Relies on/discussed further in dotnet/corefx#312

  10. iSazonov commented on Nov 26, 2019

    @iSazonov
    Collaborator

    Fixed in #11042

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aResolution-FixedThe issue is fixed.WG-Cmdletsgeneral cmdlet issuesWaiting - DotNetCorewaiting on a fix/change in .NET

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions