Subject: bug#17878: closed (Re: bug#17878: Possible bug in GNU ls with -R)

From: [email-masked] (GNU bug Tracking System)
Date: Mon, 30 Jun 2014 13:24:03 +0000

Your bug report

#17878: Possible bug in GNU ls with -R

which was filed against the coreutils package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
17878: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=17878
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#17878: Possible bug in GNU ls with -R
From: Eric Blake <[email-masked]>
To: [email-masked], [email-masked]
Date: Mon, 30 Jun 2014 07:23:32 -0600
List-Id: <debbugs-submit.debbugs.gnu.org>

tag 17878 notabug
thanks

On 06/29/2014 12:06 PM, [email-masked] wrote:

>     $ ls -RF
>     .:
>     foo  bar*  baz

>> If more than one directory, or a combination of non-directory files
>> and directories are written, either as a result of specifying
>> multiple operands, or the -R option, each list of files within a
>> directory shall be preceded by:

> In the case described above, ls writes a listing for one directory (.)
> and does not list any non-directory files. Therefore, according to the
> above specification, the ".:" heading may not be printed, but GNU ls
> does do so. I suspect this is an oversight on the side of the
> developers of the GNU coreutils.

This is a mis-interpretation of POSIX.  You missed the "or the -R
option" phrase, which implies this behavior is turned on unconditionally
when a directory is listed recursively even if that directory does not
contain a mix of non-directory files and directories.  That is, the
behavior of listing a directory at the front is triggered either by
specifying multiple command line arguments (either 2 or more
directories, or 1 directory and at least one other argument); or by
using -R.  Another way of looking at it is that you are listing a
combination of directories and regular files - the directory '.'
(implicitly supplied by not giving any arguments) and the regular files
of its contents.

All other ls implementations behave the same.  This is not a bug in
coreutils.  I'm closing the report, although you can feel free to add
more comments.  If you think the wording in POSIX is awkward, then file
a bug there to get it cleaned up (http://austingroupbugs.net/)

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Subject: Possible bug in GNU ls with -R
From: [email-masked]
To: [email-masked]
Date: Sun, 29 Jun 2014 20:06:30 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

I think I found behavior in GNU ls that deviates from the behavior
specified by POSIX.1 2008:

If GNU ls is called on one directory without subdirectories with the
option -R, it prints a directory heading like this:

    $ ls -RF
    .:
    foo  bar*  baz

POSIX.1 2008[1] says about this directory heading:

> If more than one directory, or a combination of non-directory files
> and directories are written, either as a result of specifying
> multiple operands, or the -R option, each list of files within a
> directory shall be preceded by:
>
>     "\n%s:\n", <directory name>
>
> If this string is the first thing to be written, the first <newline>
> shall not be written. This output shall precede the number of units
> in the directory.

In the case described above, ls writes a listing for one directory (.)
and does not list any non-directory files. Therefore, according to the
above specification, the ".:" heading may not be printed, but GNU ls
does do so. I suspect this is an oversight on the side of the
developers of the GNU coreutils.

I am using the following version of GNU ls:

    $ ls --version

    ls (GNU coreutils) 8.20
    Copyright (C) 2012 Free Software Foundation, Inc.
    License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
    This is free software: you are free to change and redistribute it.
    There is NO WARRANTY, to the extent permitted by law.

    Written by Richard M. Stallman and David MacKenzie.

Thank you very much for your help.
Yours sincerely,
Robert Clausecker

[1]: http://pubs.opengroup.org/onlinepubs/9699919799/utilities/ls.html

-- 
()  ascii ribbon campaign - for an 8-bit clean world 
/\  - against html email  - against proprietary attachments