The following issue has been SUBMITTED. ====================================================================== http://austingroupbugs.net/view.php?id=1147 ====================================================================== Reported By: stephane Assigned To: ====================================================================== Project: 1003.1(2016)/Issue7+TC2 Issue ID: 1147 Category: Shell and Utilities Type: Enhancement Request Severity: Editorial Priority: normal Status: New Name: Stephane Chazelas Organization: User Reference: Section: ls utility Page Number: 2923-2927 Line Number: 96644,96693,96785->96793 Interp Status: --- Final Accepted Text: ====================================================================== Date Submitted: 2017-06-15 20:41 UTC Last Modified: 2017-06-15 20:41 UTC ====================================================================== Summary: ls -l -F/-p and symlinks Description: The ls spec currently says that with -F, some characters may be appended after each "pathname" to identify the type and after each "filename" for -p (though only for directories).
It doesn't say which filename/pathname it should apply to in the case of symlinks where both the file and the target of the symlink are listed like in ls -l/-n output. I see different behaviours across implementations GNU: <pre> $ ls -lp total 4 drwxr-xr-x 2 chazelas chazelas 4096 Jun 15 21:01 dir/ lrwxrwxrwx 1 chazelas chazelas 3 Jun 15 21:01 dir-link -> dir prw-r--r-- 1 chazelas chazelas 0 Jun 15 20:59 fifo lrwxrwxrwx 1 chazelas chazelas 4 Jun 15 20:59 fifo-link -> fifo $ ls -lF total 4 drwxr-xr-x 2 chazelas chazelas 4096 Jun 15 21:01 dir/ lrwxrwxrwx 1 chazelas chazelas 3 Jun 15 21:01 dir-link -> dir/ prw-r--r-- 1 chazelas chazelas 0 Jun 15 20:59 fifo| lrwxrwxrwx 1 chazelas chazelas 4 Jun 15 20:59 fifo-link -> fifo| </pre> busybox: <pre> $ busybox ls -lp total 4 drwxr-xr-x 2 chazelas chazelas 4096 Jun 15 21:01 dir/ lrwxrwxrwx 1 chazelas chazelas 3 Jun 15 21:01 dir-link -> dir/ prw-r--r-- 1 chazelas chazelas 0 Jun 15 20:59 fifo lrwxrwxrwx 1 chazelas chazelas 4 Jun 15 20:59 fifo-link -> fifo $ busybox ls -lF total 4 drwxr-xr-x 2 chazelas chazelas 4096 Jun 15 21:01 dir/ lrwxrwxrwx 1 chazelas chazelas 3 Jun 15 21:01 dir-link -> dir/ prw-r--r-- 1 chazelas chazelas 0 Jun 15 20:59 fifo| lrwxrwxrwx 1 chazelas chazelas 4 Jun 15 20:59 fifo-link -> fifo| </pre> FreeBSD: <pre> $ ls -lp total 4 drwxr-xr-x 2 chazelas chazelas 512 Jun 15 20:01 dir/ lrwxr-xr-x 1 chazelas chazelas 3 Jun 15 20:01 dir-link -> dir prw-r--r-- 1 chazelas chazelas 0 Jun 15 19:59 fifo lrwxr-xr-x 1 chazelas chazelas 4 Jun 15 19:59 fifo-link -> fifo $ ls -lF total 4 lrwxr-xr-x 1 chazelas chazelas 6 Jun 15 20:05 broken@ -> broken drwxr-xr-x 2 chazelas chazelas 512 Jun 15 20:01 dir/ lrwxr-xr-x 1 chazelas chazelas 3 Jun 15 20:01 dir-link@ -> dir prw-r--r-- 1 chazelas chazelas 0 Jun 15 19:59 fifo| lrwxr-xr-x 1 chazelas chazelas 4 Jun 15 19:59 fifo-link@ -> fifo </pre> Solaris 10: <pre> $ ls -lp total 10 lrwxrwxrwx 1 chazelas other 6 Jun 15 21:07 broken -> broken drwxr-xr-x 2 chazelas other 512 Jun 15 21:01 dir/ lrwxrwxrwx 1 chazelas other 3 Jun 15 21:07 dir-link -> dir/ prw-r--r-- 1 chazelas other 0 Jun 15 20:59 fifo lrwxrwxrwx 1 chazelas other 4 Jun 15 21:07 fifo-link -> fifo $ ls -lF total 10 lrwxrwxrwx 1 chazelas other 6 Jun 15 21:07 broken -> broken drwxr-xr-x 2 chazelas other 512 Jun 15 21:01 dir/ lrwxrwxrwx 1 chazelas other 3 Jun 15 21:07 dir-link -> dir/ prw-r--r-- 1 chazelas other 0 Jun 15 20:59 fifo| lrwxrwxrwx 1 chazelas other 4 Jun 15 21:07 fifo-link -> fifo </pre> Desired Action: Use "pathname" instead of "filename" consistently for "-p" and "-F". For symlink in ls -lLF or ls -lLp (without -L/-H), leave it unspecified whether the character is appended to the symlink or its target or both, but when it's to the file, it should be based on the type as obtained from lstat(), and when it's to the target, it should be based on the type as obtained from stat(). For -p, for symlinks to directories, leave it unspecified whether a / is appended, but that if one is appended, it should be to the target of the symlink. IMO, Solaris' ls -lF output of: lrwxrwxrwx 1 chazelas other 4 Jun 15 21:07 fifo-link -> fifo should be considered a bug, I would expect a @ after the link, or | after the fifo (the latter in that case for consistency with the "dir-link -> dir/"). We should probably make it clearer that by "target of the symlink" we mean after *full* symlink resolution (so not the target as in what appears after the "->" which may very well identify another symlink). ====================================================================== Issue History Date Modified Username Field Change ====================================================================== 2017-06-15 20:41 stephane New Issue 2017-06-15 20:41 stephane Name => Stephane Chazelas 2017-06-15 20:41 stephane Section => ls utility 2017-06-15 20:41 stephane Page Number => 2923-2927 2017-06-15 20:41 stephane Line Number => 96644,96693,96785->96793 ======================================================================