'ls -l' in symbolic link directory on Windows lists the link itself instead of the target directory contents
Description
When using ls -l inside a symbolic link directory (created as a symlink to another directory) on Windows, the command only displays the symbolic link itself rather than the contents of the target directory. This behavior does NOT occur when running ls without the -l flag.
# ls -l
total 0
dr-xr-xr-x 1 somebody somegroup 0 May 1 22:30 apps
drwxrwxrwx 1 somebody somegroup 0 Mar 23 14:15 media
lr-xr-xr-x 1 somebody somegroup 0 Mar 23 14:36 pkgs -> 'E:\pkgs'
lr-xr-xr-x 1 somebody somegroup 0 May 1 23:21 scoop -> '.\apps\scoop'
# cd scoop && ls -l
lr-xr-xr-x 1 somebody somegroup 0 May 1 23:21 . -> '.\apps\scoop'
# ls
apps buckets modules persist scoop.db shims workspace
Environment
OS infomation
版本 Windows 11 专业版 版本号 24H2 安装日期 2025/2/16 操作系统版本 26100.3915 体验 Windows 功能体验包 1000.26100.83.0
ls version
ls 0.0.30
commit 2c130ae7 changed the behavior of -l option, though can't find why.
update: i posted this in the wrong issue
it has the same behavior on redox os
Just to clarify my own understanding, on Unix the behaviour is to list the link if a path to a directory symlink is given. However, if the path is . then it lists the directory instead of showing the link.
Presumably the reason for this is that on unix the current directory is actually being resolved to the real directory before ls interacts with it whereas on Windows it's being used exactly as set. One possible workaround would be to special case the handling of . to always list the directory but I don't know if that would have any unwanted effects.