bug-coreutils
[Top][All Lists]
Advanced

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

Re: Slash appears twice using ls -ldF


From: Eric Blake
Subject: Re: Slash appears twice using ls -ldF
Date: Sat, 04 Feb 2006 02:23:33 +0000

> you dont need the -l to reproduce, but it only happens when <SOME_DIRECTORY> 
> itself ends in a /
> 
> $ ls -dF /bin
> /bin/
> $ ls -dF /bin/
> /bin//
> 
> happens with 5.93 as well

What do other systems do in this case?

POSIX states only "-F ... Write a slash ( '/' ) immediately after each pathname
that is a directory...", and "-p Write a slash ( '/' ) after each filename if 
that
file is a directory," without any requirement I could see to either avoid or
to print a double trailing slash when the directory name itself already had one
(necessarily from a command line argument, since readdir(2) should not be
appending a trailing slash).

But, there are systems where / and // are distinct, and one could argue (as
this thread has done) that if a directory already has a trailing slash,
appending another one not only looks weird, but in the case of roots,
changes the filename being printed! (in all other cases, a redundant trailing
slash does not change the interpretation of the filename printed)

$ \ls -iFd1 / //
17178693578447192817 //
             6035200 ///
$ \ls -id1 // ///
             6035200 //
17178693578447192817 ///

Unless someone can think of a reason to always append the trailing
slash, even when the filename already ended in slash, I would be
in favor of a patch that uses the silence of POSIX as justification
to surpress the extra slash under -F, -p, and --indicator-style when
the filename already ended in slash.

One other thing to think about.  When -F is used in conjunction with
--color, the indicator is currently printed after color has been restored
to normal (see the dump below), so the color change gives visual
indication that a file type indicator was appended.  In this case, omitting
a redundant trailing slash would be inconsistent next to directories that
were spelled without a trailing slash (otherwise, some trailing / would
be colored and others not).  Should ls start coloring the filetype indicator,
so that omitting a redundant slash doesn't give inconsistent colors?  Or
should omitting the redundant slash only be performed if --color is
not in effect?

$ ls -dp --color=always / // | od -tx1z -An
 1b 5b 30 30 6d 1b 5b 30 31 3b 33 34 6d 2f 1b 5b  >.[00m.[01;34m/.[<
 30 30 6d 2f 0a 1b 5b 30 31 3b 33 34 6d 2f 2f 1b  >00m/..[01;34m//.<
 5b 30 30 6d 2f 0a 1b 5b 6d                       >[00m/..[m<


--
Eric Blake




reply via email to

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