

Three Cats  - tptacek
http://thenewsh.blogspot.com/2010/03/three-cats.html

======
CoreDumpling
Point: Bloat in cat is bad and un-UNIXy, cf. <http://harmful.cat-v.org/cat-v/>

Counter-point: If cat is becoming your performance bottleneck, you're doing it
wrong: <http://sial.org/howto/shell/useless-cat/>

Yes, the GNU version looks dreadful, but I think that really doesn't matter
that much.

EDIT: Well, I guess I didn't consider the case where you want to put cat in a
chroot jail. On Solaris 10:

$ ldd /usr/bin/cat

    
    
        libc.so.1 =>         /lib/libc.so.1
        libm.so.2 =>         /lib/libm.so.2
        /platform/SUNW,T5240/lib/libc_psr.so.1
    

$ ldd /usr/gnu/coreutils/default/bin/cat

    
    
        libnsl.so.1 =>       /lib/libnsl.so.1
        libc.so.1 =>         /lib/libc.so.1
        libmp.so.2 =>        /lib/libmp.so.2
        libmd.so.1 =>        /lib/libmd.so.1
        libscf.so.1 =>       /lib/libscf.so.1
        libdoor.so.1 =>      /lib/libdoor.so.1
        libuutil.so.1 =>     /lib/libuutil.so.1
        libgen.so.1 =>       /lib/libgen.so.1
        libm.so.2 =>         /lib/libm.so.2
        /platform/SUNW,T5240/lib/libc_psr.so.1
        /platform/SUNW,T5240/lib/libmd_psr.so.1
    

Yikes...

~~~
barrkel

        [rupert] ~$ ldd $(which cat)
                libintl.so.3 =>  /lib/libintl.so.3
                libiconv.so.2 =>         /lib/libiconv.so.2
                libc.so.1 =>     /lib/libc.so.1
                libsocket.so.1 =>        /lib/libsocket.so.1
                libgcc_s.so.1 =>         /lib/libgcc_s.so.1
                libsec.so.1 =>   /lib/libsec.so.1
                libnsl.so.1 =>   /lib/libnsl.so.1
                libavl.so.1 =>   /lib/libavl.so.1
                libidmap.so.1 =>         /usr/lib/libidmap.so.1
                libmp.so.2 =>    /lib/libmp.so.2
                libmd.so.1 =>    /lib/libmd.so.1
                libscf.so.1 =>   /lib/libscf.so.1
                libldap.so.5 =>  /usr/lib/libldap.so.5
                libresolv.so.2 =>        /lib/libresolv.so.2
                libsldap.so.1 =>         /usr/lib/libsldap.so.1
                libuutil.so.1 =>         /lib/libuutil.so.1
                libgen.so.1 =>   /lib/libgen.so.1
                libsasl.so.1 =>  /usr/lib/libsasl.so.1
                libnspr4.so =>   /usr/lib/libnspr4.so
                libplc4.so =>    /usr/lib/libplc4.so
                libnss3.so =>    /usr/lib/libnss3.so
                libssl3.so =>    /usr/lib/libssl3.so
                librt.so.1 =>    /lib/librt.so.1
                libdl.so.1 =>    /lib/libdl.so.1
                libsoftokn3.so =>        /usr/lib/libsoftokn3.so
                libplds4.so =>   /usr/lib/libplds4.so
                libm.so.2 =>     /lib/libm.so.2
    

(Nexenta NCP 2.0; there's a simpler cat in /usr/sun/bin.)

------
blasdel
My favorite is _true_ :
[http://git.savannah.gnu.org/gitweb/?p=coreutils.git;a=blob;f...](http://git.savannah.gnu.org/gitweb/?p=coreutils.git;a=blob;f=src/true.c;h=e750e40a1e87ddffa579bcacd2951d2ab2b01545;hb=HEAD)

Solaris used to have one that was a shell script that contained only copyright
header comments and no code. The current OpenSolaris one looks sane:
[http://src.opensolaris.org/source/xref/onnv/onnv-
gate/usr/sr...](http://src.opensolaris.org/source/xref/onnv/onnv-
gate/usr/src/cmd/true/true.c)

------
BoppreH
I loved the comments in the GNU cat.

"Why are (OUTSIZE - 1 + INSIZE * 4 + LINE_COUNTER_BUF_LEN + PAGE_SIZE - 1)
bytes allocated for the output buffer?"

Then it goes on a 15 lines article, divided in two paragraphs, explaining the
reasoning behind the code.

~~~
unwind
Yeah ... I enjoyed "An 11 digit counter may overflow within an hour on a
P2/466", too. GNU obviously overclock their hardware, the Wikipedia page for
the Pentium II says it topped out at 450 MHz, in 1999.

------
olefoo

       cat --vet
    

The gnu cat comes with it's own vet ;-)

I actually use this feature and am grateful for it's existence.

~~~
trevelyan
Out of curiosity, what exactly do you use it for? Couldn't matching on newline
accomplish the same end?

~~~
olefoo
Most common use is to find control characters in a file where they shouldn't
be.

------
derefr
The GNU version might look intimidating, but I think that's just the code
style getting in the way. I'm betting that, compiled to assembler, it doesn't
consist of many more tokens than the first version. (Anyone care to test?
Don't have a toolchain in front of me at the moment.)

------
tptacek
One of them gives Tim an aneurysm. CAN YOU GUESS WHICH?

