Cat a directory
admin at asarian-host.net
Thu Sep 25 08:29:44 PDT 2003
[it seems I forgot a paragraph]
----- Original Message -----
From: "Jerry McAllister" <jerrymc at clunix.cl.msu.edu>
To: "Mark" <admin at asarian-host.net>
Cc: <freebsd-questions at freebsd.org>
Sent: Thursday, September 25, 2003 4:21 PM
Subject: Re: Re:Re: Cat a directory
> > I would like to see a switch added to cat, like "-d", which specifically
> > allows it to operate on directories too, for that once-in-a-million
> > chance I actually need a hex dump on the directory as file. In fact,
> > that behavior is already incorporated in the "rm" command:
> Again, rm is something very different.
But nonetheless very illustrative of how the OS takes into consideration an
unexpected, and probably unintended, behavior; namely, unlinking a
directory, whereas the user expects it to operate on regular files. Hence,
by default, it does NOT unlink directories, and only does so when you
specifically add the -d (-r) override. And that, to me, makes perfect sense.
Moreover, I feel the same logic should apply to "cat".
> If you want a special flag to make cat treat directories specially,
> then go ahead and write it and submit it. BUT DO NOT CHANGE THE
> DEFAULT BEHAVIOR OF CAT OR YOUR MODIFICATION WILL BE REJECTED BECAUSE IT
> WOULD BREAK THOUSANDS OF SCRIPTS AND BE FOOLISH AND UNNECESSARY!!!!!!!!
Uh-uh; and no default behavior has ever been changed over the years, eh? :)
And what is with these "thousands of scripts" that would suddenly break
horribly? So far, I have only heard one good scenario: a specific instance
where one would wish to obtain a hex-dump on the actual contents of the
directory file; and I even doubt such a use would find its way to a script
(as it would probably be a one-time use for debugging/finding lost files or
something). In 99.9 percent you will find that "cat" is used on regular
files. That figure is actually probably closer to 99.99999 percent; but I'll
be mild. When you spell it out like that, what should be allowed to call
itself "default behavior" becomes clear.
> Now, either contribute something or be done with it.
I contributed a few clear, well-argumented reasons in favor of my position
that "cat" should change its default behavior. You, otoh, have only
demonstrated that you are a bully, and that you can yell real loud. Well,
that don't impress me much.
More information about the freebsd-questions