Cat a directory
Ruben de Groot
mail25 at bzerk.org
Fri Sep 19 03:34:10 PDT 2003
On Fri, Sep 19, 2003 at 08:27:00AM +0300, Karlsson Mikael HKI/SOSV typed:
> 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
> it causes.
So why don't you for example alias cat to cat -v in your system profile
and login scripts? This will display non-printing characters so they are
visible and don't mangle terminal settings.
> 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.
Why not? I regularly use constructs like this:
cat somebackup.tgz | ssh someserver "cd /somedir; tar xzf -"
> 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?
Because less != cat. It has a completely different functionality.
> 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
> freebsd-questions at freebsd.org mailing list
> To unsubscribe, send any mail to "freebsd-questions-unsubscribe at freebsd.org"
The world is coming to an end. Please log off.
More information about the freebsd-questions