Cat a directory
Karlsson Mikael HKI/SOSV
mikael.karlsson at hel.fi
Thu Sep 18 22:27:39 PDT 2003
OK! I admit that it isn't THE BIGGEST problem for me BUT it is A problem. What
I ment in my last mail was that it is the biggest problem concerning cat. Since
someone always seems to cat a binary file without having the knowledge of what
I personally think that some of these tests should be added to the real
distributable version of cat that comes with FreeBSD cause I can't be the only
one that this bugs. I mean what could a little more code hurt to the program
since cat isn't supposed to read binary files.
I could add the code myself to cat's source file and compile it so my users
won't be able to cat binary files and stuff like that but what happens to the
thousands of other people that is bugged by the same problem, are they supposed
to do the same re-coding that I did? Or couldn't this simply be added to the
distribution source file so others won't be bugged.
Other *NIX systems seem to have done this to their cat program so why can't
FreeBSD? and why is this already done to less and not cat?
Dan Nelson wrote (18.9.2003 17:33):
>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