ls -A (was: Multiple Root ID's considered evil?)

John Macdonald jmm at eci386.uucp
Sat Oct 7 06:11:07 AEST 1989


In article <14611 at bloom-beacon.MIT.EDU> scs at adam.pika.mit.edu (Steve Summit) writes:
>In article <15 at minya.UUCP> jc at minya.UUCP (John Chambers) writes:
>>I won't say what I'd like 
>>to do to the geniuses who decide that commands like ls should behave
>>differently for user 0 than for all other users.  [...]
>
>You mean ls -A is implicit if getuid() returns 0?  Funny, I'd
>never noticed.

(Are you sure you've spent enough time as root to qualify as a
wizard? :-)

>                I _like_ -A; I've essentially got ls aliased to
>always include it.

Me too, or at least I did back when I was on a Xenix system that
had a Berkeley-style ls.

>                    I've never understood why there would be
>certain files you never want to see, or why a simple bijection
>based on the first character of the filename is a useful and
>general selection model.  Selecting a command's operands and
>restricting its output is what shell metacharacters and grep are
>for.  I think ls should list my directory, not list some of my
>directory.  ("Every function should do exactly one job, and do it
>well.")  The shells conspire with ls to perpetuate this misguided
>discrimination against "dot" files: it's irritating that I have
>to type things like
>
>	rm *~ .*~
>
>to remove _all_ the backup files GNU emacs might have left around.

Like all things, treating .* files specially has advantages and
disadvantages.  Some form of special treatment *was* necessary -
otherwise "rm *" would remove "." and ".."!  Making the rule be
    "anything beginning with '.' is special"
rather than
    "'.' and '..' are special"
meant that the rule about "special" files would be extensible.  (If
a new release of Unix had added, for example "..." as a link to the
root directory of its file system, or if any other possible extension
had come along, the current rule would have continued to work without
any change.)  As a side benefit this rule provided the option of
having files that weren't automatically displayed.

>Anyway, getuid() is one of the least expensive system calls known.

The expense is not the problem, the inconsistancy is the problem.
Your fingers type a command, and it appears to work, but it is
actually working a little bit differently than you expect, but you
might not notice.  What is really infuriating about the special case
in "ls" (i.e. -A is turned on by default for root, off otherwise) is
that the -A flag is a toggle: if you simply alias ls to "ls -A", then
it *stops* displaying . files when you are root.

A minor annoyance about AT&T "ls" is that it doesn't have that -A at
all, with or without silly choices for defaults.  Thus to see all
your files, you also have to see "." and ".." (fortunately, I can
ignore them without too much mental strain).
-- 
"Software and cathedrals are much the same -          | John Macdonald
first we build them, then we pray" (Sam Redwine)      |   jmm at eci386



More information about the Comp.unix.wizards mailing list