[TUHS] A question about ls(1)

Warner Losh imp at bsdimp.com
Sun Apr 28 01:38:27 AEST 2019

On Sat, Apr 27, 2019 at 8:26 AM Anthony Martin <ality at pbrane.org> wrote:

> From at least V2 to V6, the ls(1) command would not
> show directory entries whose names began with a '.'
> unless the -a flag was supplied.
> This was changed in V7: only the directory entries
> for "." and ".." would be skipped by default.

gnu ls does not follow this convention. The system V sources one can find
on the internet have the curious code:

#define DOTSUP  1
                        if (aflg==0 && dentry->d_name[0]=='.'
# ifndef DOTSUP
                                && (dentry->d_name[1]=='\0' ||
                                && dentry->d_name[2]=='\0')
# endif
                                )  /* check for directory items '.', '..',
                                   *  and items without valid inode-number;

which is the V7 behavior ifdef'd out.

> All further versions of Research Unix retain the
> convention of V7 and Plan 9 ultimately made it
> unnecessary. However, BSD and its descendants did
> not follow suit. Instead, they continued behaving
> like V6 with an additional -A flag to emulate V7.

This has been the BSD convention since at least 4BSD :)

But I find this interesting, since the 8th edition was based on BSD 4.1c I

And system III and later all have the above code.

> Was the initial behavior intentional or just a
> matter of expediency?
> Who made the change and what was their motivation?
> Was it a reaction to the intentional hiding of what
> came to be known as "dot files"?

It looks like, from the source, to be a blip in V7.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://minnie.tuhs.org/pipermail/tuhs/attachments/20190427/5c17ffac/attachment.html>

More information about the TUHS mailing list