From owner-freebsd-questions@FreeBSD.ORG Wed Sep 24 20:42:56 2003 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 2B19016A4B3 for ; Wed, 24 Sep 2003 20:42:56 -0700 (PDT) Received: from asarian-host.net (mail.asarian-host.net [194.109.160.70]) by mx1.FreeBSD.org (Postfix) with ESMTP id D1DA64400B for ; Wed, 24 Sep 2003 20:42:52 -0700 (PDT) (envelope-from admin@asarian-host.net) Comments: To protect the identity of the sender, certain header fields are either not shown, or masked. Anonymous email accounts can be requested by filling in the appropriate form at: https://asarian-host.net/cgi-bin/signup.cgi Received: (from root@localhost) by mail.asarian-host.net (8.12.10/8.12.10) id h8P3gpLw067620 for freebsd-questions@freebsd.org; Thu, 25 Sep 2003 05:42:51 +0200 (CEST) (envelope-from admin@asarian-host.net) From: Mark Message-Id: <200309250342.H8P3GORP067610@asarian-host.net> Date: Thu, 25 Sep 2003 03:42:50 GMT X-Authenticated-Sender: admin@asarian-host.net X-Trace: RT4aQffyoRgo34JmTVpjVCLK/abJoNbtVAi8WnBWmsytiVbiw3Qqtj6RtOqAWZyL/K/fiMAaSFEafV36kC4fnw== X-Complaints-To: abuse@asarian-host.net X-Abuse-Info: Please be sure to forward a copy of ALL headers X-Abuse-Info: Otherwise we are unable to process your complaint Organization: Asarian-host To: References: <20030919083627.K99065@wonkity.com> <20030922162119.GA78498@wopr.caltech.edu> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 X-Auth: Asarian-host PGP signature iQEVAwUAP3JkOzFqW1BleBN9AQHf/QgAlQkk1mt75GDx59o9gHa8Gqud+Nv2TR0u K0opqxoSRlfPZ1DrmeusKbA2hZZle+lk/xPlr9sfq51Y5KUBct9ar1cj0iZNTxrf W6Fig6gSlKTI/p35AQrRfdaVV4k7rcJRZJ4SAjEp2BkuW4ivcvVcJo/OpBU3JtRJ S3KdPx3uA9HAUvP2uIHJB8QSkI2CjrkiCZ5tTE70QpWisWarnzz18JwKJYWue/eF p870jLn3qYyFxmpc5JA3IQ96+tWDrCzzAOc0D9XEhYbcb0HWNJA+8yX1TD3ukzVd 4NyX5kvDfzLupIy9tH+WZ9Nmbf/Yyj5Hdhm5WFmYnm7q/+8WFKKZVg== =mpKh Subject: Re: Re:Re: Cat a directory X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 25 Sep 2003 03:42:56 -0000 ----- Original Message ----- From: "Matthew Hunt" To: "Karlsson Mikael HKI/SOSV" Cc: Sent: Monday, September 22, 2003 6:26 PM Subject: Re: Re:Re: Cat a directory > "cat /bin" on Solaris 9 does exactly the same thing as on FreeBSD; shows > the contents of the directory, just like you're asking it to. Just because > you can't fathom a use for this behavior doesn't mean it's wrong. If you > don't want to see it, don't ask "cat" to show it to you. Answers like this are not uncommon. I guess because it evokes the old "This separates the men from the boys" attitude. However, the purpose of "cat" is to write the contents of a file to STDOUT. And yes, in UNIX pretty much everything is considered a file. But that does not change the fact that people do not experience a directory as a file, and in their use of language also clearly differentiate between the two. You too. Besides, for the regular use of writing the contents of a directory to STDOUT, "ls" was created. Using "cat /bin" is a poor example, because everybody KNOWS /bin is a directory. But how about using a more realistic example? Say, "cat /usr/libexec/sendmail"? That happens to be a directory, but could easily be mistaken for a regular file (when found in a find output, for instance). And then a lot of crap scrolls through your terminal, which is potentially DANGEROUS. Just because you cannot fathom a legitimate situation in which a cat on a directory was unexpected and unintentional, does not mean that situation never occurs. 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: The options are as follows: -d Attempt to remove directories as well as other types of files. So, in like fashion for "cat": -d Attempt to write the raw contents of a directory too. - Mark