[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, 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.

> 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.

> dwarf:/etc/X11# ls -p
> WindowMaker/      XF86Config.test3      Xsession.options         twm/
> X@                XF86Config.works.xf3  Xwrapper.config          wdm/
  (...)

-- 
Flávio



Reply to: