[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#9637: ls appends an indicator even if one is already present (--indi

From: Eric Blake
Subject: bug#9637: ls appends an indicator even if one is already present (--indicator-style=classify)
Date: Fri, 30 Sep 2011 11:35:56 -0600
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv: Gecko/20110906 Fedora/3.1.14-1.fc14 Lightning/1.0b3pre Mnenhy/0.8.3 Thunderbird/3.1.14

tag 9637 notabug

On 09/30/2011 04:42 AM, Philip Ganchev wrote:
"Ls --indicator-style=classify" always appends a slash to the names of
directories. For example:

ls -d */

dir1// dir2//

Correct, and this behavior is required by POSIX:


Do not follow symbolic links named as operands unless the -H or -L options are specified. Write a <slash> ( '/' ) immediately after each pathname that is a directory, an <asterisk> ( '*' ) after each that is executable, a <vertical-line> ( '|' ) after each that is a FIFO, and an at-sign ( '@' ) after each that is a symbolic link. For other file types, other symbols may be written.

Write a <slash> ( '/' ) after each filename if that file is a directory.

Neither of those options mention that the slash may be omitted if the user's command-line option already included a slash. We'd have to take it up with the POSIX folks to get that changed, before we could change coreutils' behavior.

In particular, we have to be careful that:

ls -p / // ///

does not make the results ambiguous. That is, while / and /// are necessarily the same directory, / and // can differ, so if we omit adding an extra slash because one is already present, then we risk confusing scripts that depend on stripping the trailing slash added by -p to convert the traditional output back into the proper directory names.

Ls should check if an indicator is already present after the end of
the file name, and append it only if it is not.

It's worth requesting that as an enhancement to POSIX, but I don't see coreutils making any changes here unless a POSIX change is made first to permit such an output optimization.

Eric Blake   address@hidden    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

reply via email to

[Prev in Thread] Current Thread [Next in Thread]