[net.unix-wizards] The Visible Cat

cottrell@nbs-vms.ARPA (03/01/85)

> What kind of thinking?  The notion that the availability of N options
> in "cat" is what makes 4.2BSD great?  Sorry, 'taint so.  A simple
> linenumbering utility ("simple" here excludes "nl" - does anybody actually
> use all the subsubsubsubsection stuff there?) does the job of "cat -n"
> quite nicely, and a simple visual display utility does the job of "cat -v"
> equally well.  Putting both those functions into "cat" makes as much sense
> as putting file copying, file deleting, file renaming, directory listing,
> etc., etc. into a program named, for the sake of argument, "PIP".
> 
> Besides, System V has, unfortunately, picked up "cat -v".
> 
> 	Guy Harris
> 	{seismo,ihnp4,allegra}!rlgvax!guy

I am referring to the extreme notion that if cat is to retain its 
pedigree as a `pure unix tool' that it must have no other funxion but
the simple concatenation of files. This is the Moral Equivalent Of War!
(MEOW :-) Why was the notion of options invented? To do the same thing
just a little bit differently. That's what I want to do.

Let's say I want to look at some mostly-printable but slightly-
infected-by-control-character ascii files, number please. I do
cat -nv file. Doing it your way would require:

	cat file | num | vis

This loads three programs and runs the data thru two pipes. Yuk!
From the user's point of view, `cat' is what the user types
to type his file. Let's get User Friendly (user friendly), I wanna get...
This poor guy would like to type `type file...'. I realize this is
`just a special case' but it's the most common usage for most users.

Axually, tho, you are right, but not for the reasons stated by you or
even DMR. Having thought about it, I realize there is a better way.
In its pure form, cat can use read's & write's. No need to look at every
char. The -v option belongs in `pr', which is already a formatting
program. It already does -n. Recondition ourselves to use pr
instead of cat. However, the default should be to always make funny
chars visible, and use -v to output verbatim. Pr is mostly used to
send things to the printer, which barfs at control chars anyway.

Saying things like putting in features just makes the manual thicker
does not communicate your reasoning to someone who likes a particular
feature. As I said, we can get rid of `cp' by using `cat <from >to'.
However, if one is going to argue against a specific implementation
of a feature, one must be prepared to offer it somewhere else.

My SYS V (Motorola port, V.0) has no cat -v. It has no pg either. TPC
dragged their feet on any kind of screen editor and still does not
have csh or the multicolumn ls that DMR railed against. It was 
instructive to read his thoughts on multicolumn filters and in fact I
wrote /bin/lm that contains the line `ls $* | pr -at5'. While I can
see that features for features sake is cancerous, lack of funxionality
is annoying, user hostile, and just plain boring. Joe Random Hacker
(he's back, folx!) wants to see his files in a pretty-printed format,
he doesn't care that the ouput can be piped to grep or sed in a
one-file-per line format. Tools should serve their masters.

"Use your mentality, wake up to reality"

	jim
*/

guy@rlgvax.UUCP (Guy Harris) (03/01/85)

> Let's get User Friendly (user friendly), I wanna get...
> This poor guy would like to type `type file...'. I realize this is
> `just a special case' but it's the most common usage for most users.

$ cd /usr/bin
$ ed type
a
vis "$@"	# or "cat -v "$@", if you have it
.
w
q
$ chmod +x type

Next question.  Or, if you have the C shell,

% alias type vis	# or "alias type cat -v"

or, if you have the S5R2 Bourne shell, the equivalent syntax for creating
a function.  Put it in /etc/profile, if you like.

	Guy Harris
	{seismo,ihnp4,allegra}!rlgvax!guy

gwyn@Brl-Vld.ARPA (VLD/VMB) (03/01/85)

Except, in the SVR2 Bourne shell it seems there is no way to redefine
built-ins, and unfortunately they made a built-in called "type".
Gobble, gobble!

cottrell@nbs-vms.ARPA (03/01/85)

> > Let's get User Friendly (user friendly), I wanna get...
> > This poor guy would like to type `type file...'. I realize this is
> > `just a special case' but it's the most common usage for most users.
> 
> $ cd /usr/bin
> $ ed type
> a
> vis "$@"	# or "cat -v "$@", if you have it
> .
> w
> q
> $ chmod +x type
> 
> Next question.  Or, if you have the C shell,
> 
> % alias type vis	# or "alias type cat -v"
> 
> or, if you have the S5R2 Bourne shell, the equivalent syntax for creating
> a function.  Put it in /etc/profile, if you like.
> 	Guy Harris

Gee, Guy I thought you'd have more to say about cat. Maybe I said 
something you liked? Is there a `vis' in S5R2? My only change would
be to `exec vis $@'. See? I can be nice.

	jim
*/

robert@gitpyr.UUCP (Robert Viduya) (03/04/85)

><
Posted from  cottrell@nbs-vms.ARPA
> My SYS V (Motorola port, V.0) has no cat -v. It has no pg either. TPC
> dragged their feet on any kind of screen editor and still does not
> have csh or the multicolumn ls that DMR railed against. It was 
> instructive to read his thoughts on multicolumn filters and in fact I
> wrote /bin/lm that contains the line `ls $* | pr -at5'. While I can
> see that features for features sake is cancerous, lack of funxionality
> is annoying, user hostile, and just plain boring. Joe Random Hacker
> (he's back, folx!) wants to see his files in a pretty-printed format,
> he doesn't care that the ouput can be piped to grep or sed in a
> one-file-per line format. Tools should serve their masters.

Actually, System V R2 pulled a bit of "one-up-manship" on Berkeley.  The
SysVr2 ls has two extra options ('-C' and '-x') which columnate filenames
in either row-major or column-major format.  However, they still didn't
bother to check if standard output was a terminal, requiring you to
specify the option explicitly.  I kinda got away with it by using:

    ls()
    {
	if [ -t ]
	    /bin/ls -C $*
	else
	    /bin/ls $*
	fi
    }

					robert

-- 
Robert Viduya
Georgia Institute of Technology

...!{akgua,allegra,amd,hplabs,ihnp4,masscomp,ut-ngp}!gatech!gitpyr!robert
...!{rlgvax,sb1,uf-cgrl,unmvax,ut-sally}!gatech!gitpyr!robert

msb@lsuc.UUCP (Mark Brader) (03/05/85)

> ... As I said, we can get rid of `cp' by using `cat <from >to'.

Nope.  cp copies the permissions as well as the contents, if it creates
the destination file.  There's no other easy way to copy permissions.

Mark Brader