GNU bug report logs - #7433
doc: ls: improve -d/--directory description

Previous Next

Package: coreutils;

Reported by: Jari Aalto <jari.aalto <at> cante.net>

Date: Thu, 18 Nov 2010 12:42:01 UTC

Severity: wishlist

Found in version 8.5-1

To reply to this bug, email your comments to 7433 AT debbugs.gnu.org.

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

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


Report forwarded to owner <at> debbugs.gnu.org, bug-coreutils <at> gnu.org:
bug#7433; Package coreutils. (Thu, 18 Nov 2010 12:42:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Jari Aalto <jari.aalto <at> cante.net>:
New bug report received and forwarded. Copy sent to bug-coreutils <at> gnu.org. (Thu, 18 Nov 2010 12:42:01 GMT) Full text and rfc822 format available.

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

From: Jari Aalto <jari.aalto <at> cante.net>
To: submit <at> debbugs.gnu.org
Subject: ls: [manual] description for --directory is insufficient
Date: Thu, 18 Nov 2010 14:46:54 +0200
Package: coreutils
Version: 8.5-1
Severity: normal

[Forwarded from http://bugs.debian.org/603895 ]

Manual page of ls(1) reads:

       -d, --directory
              list directory entries instead of contents, and do not  derefer-
              ence symbolic links

"info ls" reads:

    `-d'
    `--directory'
         List just the names of directories, as with other types of files,
         rather than listing their contents.  Do not follow symbolic links
         listed on the command line unless the `--dereference-command-line'
         (`-H'), `--dereference' (`-L'), or
         `--dereference-command-line-symlink-to-dir' options are specified.

None of these is helpful in understanding how the option is supposed
to work:

    ls -d
    ls -dR
    ls -dr
    ls --directory -R
    ls --directory -r
    ls --directory

    => They all just return '.'

After lot of Google, a miracle command syntax is found:

    ls -d */

Please improve the documentation and give examples. Btw, the command
syntax "*/" is counterintuitive to rest of the ls(1) behavior:

       ls -a    vs.    ls -d

-- System Information
Debian Release: squeeze/sid
  APT Prefers testing
  APT policy: (990, testing) (500, unstable) (1, experimental)
Architecture: amd64
Kernel: Linux picasso 2.6.32-5-amd64 #1 SMP Fri Sep 17 21:50:19 UTC 2010 x86_64 GNU/Linux
Locale: LANG=en_DK.UTF-8

-- Versions of packages `coreutils depends on'.
Pre-Depends:
libacl1         2.2.49-4        This package contains the libacl.so dynamic l
libattr1        1:2.4.44-2      Contains the runtime environment required by 
libc6           2.11.2-7        Contains the standard libraries that are used
libselinux1     2.0.96-1        This package provides the shared libraries fo




Information forwarded to owner <at> debbugs.gnu.org, bug-coreutils <at> gnu.org:
bug#7433; Package coreutils. (Thu, 18 Nov 2010 15:13:01 GMT) Full text and rfc822 format available.

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

From: Eric Blake <eblake <at> redhat.com>
To: Jari Aalto <jari.aalto <at> cante.net>
Cc: 7433 <at> debbugs.gnu.org, 603895 <at> bugs.debian.org
Subject: Re: bug#7433: ls: [manual] description for --directory is insufficient
Date: Thu, 18 Nov 2010 08:16:56 -0700
[Message part 1 (text/plain, inline)]
On 11/18/2010 05:46 AM, Jari Aalto wrote:
> Package: coreutils
> Version: 8.5-1
> Severity: normal
> 
> [Forwarded from http://bugs.debian.org/603895 ]

Thanks for the report.

> 
> Manual page of ls(1) reads:
> 
>        -d, --directory
>               list directory entries instead of contents, and do not  derefer-
>               ence symbolic links

Which is generated from the 'ls --help' output.

> None of these is helpful in understanding how the option is supposed
> to work:
> 
>     ls -d

The wording for -d may not mention it, but the wording at the very
beginning of the --help and man page is clear that:

| Usage: ls [OPTION]... [FILE]...
| List information about the FILEs (the current directory by default).

That is, 'ls -d' is the same as 'ls -d .', as required by POSIX, at
which point you are listing the current directory as a file, and not the
contents of the current directory.

>     ls -dR

When listing directories as files (-d), no recursion (-R) takes place
because no directories are encountered, just files.  Again, this
behavior is required by POSIX.

What wording change, if any, can you propose for the --help output that
would not make things too verbose for what is supposed to be a quick
reference?

> After lot of Google, a miracle command syntax is found:
> 
>     ls -d */

Yes, that says list all directories (and symlinks to directories) in the
current directory, that don't start with leading ., as a file.

> Please improve the documentation and give examples. Btw, the command
> syntax "*/" is counterintuitive to rest of the ls(1) behavior:
> 
>        ls -a    vs.    ls -d

Yes, comparing these two in the info pages would be a useful addition
(although I'm not sure that we should bloat the already-long --help
output for this).  Could you propose a patch?

-- 
Eric Blake   eblake <at> redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

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

Information forwarded to owner <at> debbugs.gnu.org, bug-coreutils <at> gnu.org:
bug#7433; Package coreutils. (Thu, 18 Nov 2010 23:46:02 GMT) Full text and rfc822 format available.

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

From: "Alan Curry" <pacman-cu <at> kosh.dhis.org>
To: eblake <at> redhat.com (Eric Blake)
Cc: 603895 <at> bugs.debian.org, 7433 <at> debbugs.gnu.org,
	Jari Aalto <jari.aalto <at> cante.net>
Subject: Re: bug#7433: ls: [manual] description for --directory is insufficient
Date: Thu, 18 Nov 2010 18:50:18 -0500 (GMT+5)
Eric Blake writes:
> 
> The wording for -d may not mention it, but the wording at the very
> beginning of the --help and man page is clear that:
> 
> | Usage: ls [OPTION]... [FILE]...
> | List information about the FILEs (the current directory by default).

In other words, to correctly predict the behavior of "ls -d" you must
read two pieces of information that are not immediately adjacent to each
other, and use a minimal amount of thought to decide whether and how
they influence each other.

For people who read documentation all the way through, knowing that a
thorough understanding of the available tools will be a long-term
benefit, this is not a problem. Let's call these people the "smart
bears". They'll get the garbage can open easily because they're patient.

For people who only skim documentation, and not even that until they
have a problem, the obstacle is larger. If there isn't a single sentence
that tells them everything they need to know, they're not going to get
it. Let's call these people the "dumb tourists". They're impatient with
the garbage can latch, because they're holding a smelly bag of garbage.

Smart bears see a thick instruction manual and say "Hooray! Proper
documentation! I won't have to guess how it works." Dumb tourists see a
thick instruction manual and say "Screw that, reading sucks, I can guess
how it works."

man pages are written by and for smart bears. Dumb tourists don't write
documentation. Sometimes they write web pages which they optimistically
call "documentation".

Making documentation dumb-tourist-friendly inevitably makes it longer,
because it has to have a clause for each goal that the reader might want
to achieve, instead of just listing the facts and expecting the reader
to be able to put them together. The increased length bothers the smart
bears since it increases the time required to read the documentation
all the way through.

In the case of ls, I suggest that -d is special enough (since it affects
how the non-option arguments are used, unlike other ls options) that a
little extra length is justified. It would be reasonable to provide 2
separate SYNOPSIS lines, something like this:

SYNOPSIS
        ls [OPTION]... [FILE]...
        ls -d [OPTION]... [FILE]...

DESCRIPTION
        The first form lists the given FILEs, and if any of them are
        directories, the directory contents are listed. If no FILEs are
        given, the contents of the current directory are listed.

        The second form (with -d) lists the given FILEs, but any FILE
        that is a directory will not have its contents listed. With no
        FILEs given, the current directory (not its contents) is listed.

I don't care how you'd translate that to/from --help. I care about man
pages, not --help.

If that seems like giving too much attention to -d, how about this
alternative: add an EXAMPLES section. Dumb tourists love EXAMPLES
sections, and smart bears can safely skip them. It's a little bit
ridiculous that cat(1) has examples and ls(1) doesn't. ls has a lot more
options.

And the conflict between -R and -d should be explicitly mentioned. One
of them makes the other meaningless, and we should say which one.

-- 
Alan Curry




Information forwarded to bug-coreutils <at> gnu.org:
bug#7433; Package coreutils. (Fri, 30 Sep 2011 16:11:02 GMT) Full text and rfc822 format available.

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

From: Philip Ganchev <phil.ganchev <at> gmail.com>
To: 7433 <at> debbugs.gnu.org
Date: Fri, 30 Sep 2011 13:34:32 +0300
On 18 Nov 2010, Jari Aalto wrote:
>> Manual page of ls(1) reads:
>>
>>        -d, --directory
>>               list directory entries instead of contents, and do not  derefer-
>>               ence symbolic links

On 18 Nov 2010, Eric Blake wrote:
[...]
> What wording change, if any, can you propose for the --help output that
> would not make things too verbose for what is supposed to be a quick
> reference?

--help currently shows:

I would suggest:

               when listing directories, show their names instead of
contents; do not
               dereference symbolic links
or
               when listing directories, show their names, not their
contents; do not
               dereference symbolic links

These are only 13 characters (15%) longer, but are, I think, clearer.

>> "info ls" reads:
>>
>>     `-d'
>>     `--directory'
>>          List just the names of directories, as with other types of files,
>>          rather than listing their contents.  Do not follow symbolic links
>>          listed on the command line unless the `--dereference-command-line'
>>          (`-H'), `--dereference' (`-L'), or
>>          `--dereference-command-line-symlink-to-dir' options are specified.

I would suggest:

          When listing directories, list just their names like other
types of files,
          instead of listing their contents. This overrides the
`--recursive' (`-R')
          option. Do not follow symbolic links listed on the command
line unless
          the `--dereference-command-line' (`-H'), `--dereference' (`-L'), or
          `--dereference-command-line-symlink-to-dir' options are specified.

This is 55 characters (18%) longer, but clearer.

Regards,
Philip Ganchev




Severity set to 'wishlist' from 'normal' Request was from Assaf Gordon <assafgordon <at> gmail.com> to control <at> debbugs.gnu.org. (Tue, 30 Oct 2018 07:17:02 GMT) Full text and rfc822 format available.

Changed bug title to 'doc: ls: improve -d/--directory description' from 'ls: [manual] description for --directory is insufficient' Request was from Assaf Gordon <assafgordon <at> gmail.com> to control <at> debbugs.gnu.org. (Tue, 30 Oct 2018 07:17:02 GMT) Full text and rfc822 format available.

This bug report was last modified 5 years and 202 days ago.

Previous Next


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