GNU bug report logs - #12664
Not possible to list directories recursiv (-d switch ignores -R)

Previous Next

Package: coreutils;

Reported by: Vamp898 <vamp898 <at> ignaz.org>

Date: Wed, 17 Oct 2012 18:10:01 UTC

Severity: normal

Tags: notabug

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

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 12664 in the body.
You can then email your comments to 12664 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-coreutils <at> gnu.org:
bug#12664; Package coreutils. (Wed, 17 Oct 2012 18:10:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Vamp898 <vamp898 <at> ignaz.org>:
New bug report received and forwarded. Copy sent to bug-coreutils <at> gnu.org. (Wed, 17 Oct 2012 18:10:01 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Vamp898 <vamp898 <at> ignaz.org>
To: bug-coreutils <at> gnu.org
Subject: Not possible to list directories recursiv (-d switch ignores -R)
Date: Wed, 17 Oct 2012 20:01:14 +0200
Documentation says the following:

-d, --directory :: list directory entries instead of contents, and do not 
dereference symbolic links

and

-R, --recursive :: list subdirectories recursively

And this is what i get when i use ls -dR /

$ ls -dR /
/

I even tried

ls -d --recursiv -R -R -R -RRRRRRRRRRR /
/

The -R switch stand-alone works fine

Im using the coreutils 8.19 package from Archlinux




Added tag(s) notabug. Request was from Eric Blake <eblake <at> redhat.com> to control <at> debbugs.gnu.org. (Wed, 17 Oct 2012 19:46:02 GMT) Full text and rfc822 format available.

Reply sent to Eric Blake <eblake <at> redhat.com>:
You have taken responsibility. (Wed, 17 Oct 2012 19:46:03 GMT) Full text and rfc822 format available.

Notification sent to Vamp898 <vamp898 <at> ignaz.org>:
bug acknowledged by developer. (Wed, 17 Oct 2012 19:46:04 GMT) Full text and rfc822 format available.

Message #12 received at 12664-done <at> debbugs.gnu.org (full text, mbox):

From: Eric Blake <eblake <at> redhat.com>
To: Vamp898 <vamp898 <at> ignaz.org>
Cc: 12664-done <at> debbugs.gnu.org
Subject: Re: bug#12664: Not possible to list directories recursiv (-d switch
	ignores -R)
Date: Wed, 17 Oct 2012 13:44:12 -0600
[Message part 1 (text/plain, inline)]
tag 12664 notabug
thanks

On 10/17/2012 12:01 PM, Vamp898 wrote:
> Documentation says the following:
> 
> -d, --directory :: list directory entries instead of contents, and do not 
> dereference symbolic links
> 
> and
> 
> -R, --recursive :: list subdirectories recursively
> 
> And this is what i get when i use ls -dR /
> 
> $ ls -dR /
> /

Thanks for the report.  However, POSIX require -d to treat directories
as files rather than directories, and says that mixing -d and -R is
unspecified:

http://pubs.opengroup.org/onlinepubs/9699919799/utilities/ls.html
> -d
>     Do not follow symbolic links named as operands unless the -H or -L options are specified. Do not treat directories differently than other types of files. The use of -d with -R produces unspecified results.

In GNU, we take this to mean that -d always overrides -R, because
recursion makes sense only if you treat a directory as a directory, but
-d says to treat it as a file instead.

If you need to mix recursion with listing of directories, consider using
find(1), as in:

find . -type d

or with specific ls options:

find . -type d -exec ls -ld {} +

As such, I'm closing this as not a bug; but you are free to still add
comments or questions to this conversation.

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

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

Information forwarded to bug-coreutils <at> gnu.org:
bug#12664; Package coreutils. (Wed, 17 Oct 2012 20:43:02 GMT) Full text and rfc822 format available.

Message #15 received at 12664 <at> debbugs.gnu.org (full text, mbox):

From: Bob Proulx <bob <at> proulx.com>
To: 12664 <at> debbugs.gnu.org, Vamp898 <vamp898 <at> ignaz.org>
Subject: Re: bug#12664: Not possible to list directories recursiv (-d switch
	ignores -R)
Date: Wed, 17 Oct 2012 14:41:14 -0600
Vamp898 wrote:
> Documentation says the following:
> 
> -d, --directory :: list directory entries instead of contents, and do not 
> dereference symbolic links
> 
> and
> 
> -R, --recursive :: list subdirectories recursively
> 
> And this is what i get when i use ls -dR /
> 
> $ ls -dR /
> /

Right.  Because the -d said to list the directory and not the contents.
In addition to everything Eric said see also this FAQ entry:

  http://www.gnu.org/software/coreutils/faq/#ls-_002dd-does-not-list-directories_0021

Bob




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 15 Nov 2012 12:24:03 GMT) Full text and rfc822 format available.

This bug report was last modified 12 years and 220 days ago.

Previous Next


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