GNU bug report logs - #17878
Possible bug in GNU ls with -R

Previous Next

Package: coreutils;

Reported by: fuz <at> fuz.su

Date: Sun, 29 Jun 2014 18:06:02 UTC

Severity: normal

Tags: notabug

Done: Eric Blake <eblake <at> redhat.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Eric Blake <eblake <at> redhat.com>
Cc: tracker <at> debbugs.gnu.org
Subject: bug#17878: closed (Possible bug in GNU ls with -R)
Date: Mon, 30 Jun 2014 13:24:02 +0000
[Message part 1 (text/plain, inline)]
Your message dated Mon, 30 Jun 2014 07:23:32 -0600
with message-id <53B164D4.7090807 <at> redhat.com>
and subject line Re: bug#17878: Possible bug in GNU ls with -R
has caused the debbugs.gnu.org bug report #17878,
regarding Possible bug in GNU ls with -R
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs <at> gnu.org.)


-- 
17878: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=17878
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: fuz <at> fuz.su
To: bug-coreutils <at> gnu.org
Subject: Possible bug in GNU ls with -R
Date: Sun, 29 Jun 2014 20:06:30 +0200
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


[Message part 3 (message/rfc822, inline)]
From: Eric Blake <eblake <at> redhat.com>
To: fuz <at> fuz.su, 17878-done <at> debbugs.gnu.org
Subject: Re: bug#17878: Possible bug in GNU ls with -R
Date: Mon, 30 Jun 2014 07:23:32 -0600
[Message part 4 (text/plain, inline)]
tag 17878 notabug
thanks

On 06/29/2014 12:06 PM, fuz <at> fuz.su 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

[signature.asc (application/pgp-signature, attachment)]

This bug report was last modified 11 years and 16 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.