Cat a directory

Dan Nelson dnelson at allantgroup.com
Thu Sep 18 07:33:08 PDT 2003


In the last episode (Sep 18), Karlsson Mikael HKI/SOSV said:
> What I just wanted to ask was if it's absolutely necessary for cat to
> be able to work on directories. Or if it would be possible to simply
> add a check to cat that tests if the "file" being opened is a
> directory and then exits with an error message if that is the case.

The source is in /usr/src/bin/cat; add some code to stat the file and
fail if it's a directory.
 
> The biggest problem for me as a "Unix" help-person at a company is to
> always explain to newbies and less experienced users not to cat
> directories as it usually scrambles or locks the whole terminal and
> as they then turn to me to undo their mistakes. These small simple
> things give our users bad thoughts about FreeBSD and often drives
> them to use other OSs!

I find that hard to believe.  Do you also want to block catting of
executables, gzipped files, jpeg files, database files, and audio
files?  No OS does that by default.  Maybe you should teach them how to
reset their terminals when they cat binary data; ^Jreset^J should work,
assuming your TERM variable is set right.

-- 
	Dan Nelson
	dnelson at allantgroup.com


More information about the freebsd-questions mailing list