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

Re: The -d option of ls and SUS



On Thu, 19 Apr 2001, Flavio Veloso wrote:

> On Thu, 19 Apr 2001, Dale Scheetz wrote:
> 
> > I'm having trouble interpreting the meaning of the SUS description for the
> > -d option, when compared with the actual behavior and manpages for ls.
> >
> > SUS says:
> >
> > -d - Do not treat directories differently from other types of files.
> >      The use of -d with -R produces unspecified results.
> >
> > The ls manpage says:
> >
> >        -d, --directory
> >               list directory entries instead of contents
> 
> The manpage is misleading a bit, but substantially they all say the
> same thing. The default behavior of ls is to list directory contents
> if its name is specified _in the command line_. By using -d you're
> telling ls to treat those directories as ordinary files (do not
> descend into them) and show their properties instead of their
> contents.
> 
> Compare `ls /*' to `ls -d /*' instead.

The implication of both the spec and the manpage is that -d adds the
feature of displaying directories as files. Neither says anything about
not displaying files as files.

Plain ls already displays directories as files, and does not "delve" into
the contents of those directories unless you add them to the command line,
so I would expect ls, and ls -d to present the same information about the
current directory. ls -d does not do this.

> 
> > This seems to contradict the SUS, but then an example is even more
> > confusing.
> >
> > First an 'ls -p' (to show the directories), then an 'ls -d':
> 
> This has nothing to do with the -d option (-p just add a character to
> the end of file names telling what they are, as you can see from the X
> symlink below, which got a `@' attached to its name). Also AFAIK -p is
> a GNU extension.

Well, -p is called out is the SUS as only providing the slash when the
node is a directory, while the GNU version also uses the indicators *, @,
and | to indicate executable, links, and FIFOs, respectivly.

I used the -p to show which of the nodes in the first listing were
directories, to compare to the -d option usage.

> 
> > dwarf:/etc/X11# ls -p
> > WindowMaker/      XF86Config.test3      Xsession.options         twm/
> > X@                XF86Config.works.xf3  Xwrapper.config          wdm/
>   (...)
> 
So, the question still remains: "Is the behavior of Linux ls using the -d
option in compliance with with the SUS declaration, or is it different."

My impression is that it does not behave as the SUS declares it should,
but obviously others may read this different than I do.

This is the last nit I have on my plate, so what is the concensus?

Waiting is,

Dwarf
--
_-_-_-_-_-   Author of "Dwarf's Guide to Debian GNU/Linux"  _-_-_-_-_-_-
_-                                                                    _-
_- aka   Dale Scheetz                   Phone:   1 (850) 656-9769     _-
_-       Flexible Software              11000 McCrackin Road          _-
_-       e-mail:  dwarf@polaris.net     Tallahassee, FL  32308        _-
_-                                                                    _-
_-_-_-_-_-  Released under the GNU Free Documentation License   _-_-_-_-
              available at: http://www.polaris.net/~dwarf/



Reply to: