5 ms·
> I was going to mention Unix “cat” but forgot. > Wildly simple - it takes at most one argument. That is asinine. Why would a program be called ‘cat’ if it c
by teddyh 11y ago
> I was going to mention Unix “cat” but forgot.
> Wildly simple - it takes at most one argument.
That is asinine. Why would a program be called ‘cat’ if it can’t concatenate multiple files?
Also, his “grash” program is seriously deficient in the handling of signals – it completely ignores the issue. There are many subtle issues with signals which have to be handled correctly when writing a shell: http://www.cons.org/cracauer/sigint.html http://www.cons.org/cracauer/sigint.html
- yarrel 11y agocat takes as many files as you pass it, yes.
- epistasis 11y ago"cat" sounds like the abbreviation of "catenate" not "concatenate". Perhaps its possible that later versions of cat allowed more than one argument?
- RadioactiveMan 11y agoCatenate means to connect things together[1], which implies it was named with multiple files in mind. [1] https://en.m.wiktionary.org/wiki/catenate https://en.m.wiktionary.org/wiki/catenate
- epistasis 11y agoI'd think that it's chaining together the characters in the file, catenating a file to the screen. Wikipedia claims that the first version of Unix did a single file. https://en.wikipedia.org/wiki/Cat_(Unix)#History https://en.wikipedia.org/wiki/Cat_(Unix)#History Whereas "con"catenate means to link separate things together. These are minor distinctions, but if somebody is going to call things "asinine" they should at least get the pedantry correct.
- RadioactiveMan 11y agoGood to know. Reading definitions of concatenate and catenate, I was confused about whether there actually was a difference or not. Edit: that wikipedia page makes it sound like the program it replaced was the one that prints a single file to the screen.
- teddyh 11y agoThe reference Wikipedia gives for that does not actually say that the original “cat” only took one file name. What is says is that “cat”s predecessor, “pr”, only took one file name, and that “cat” subsumed it. How’s that for pedantry?
- epistasis 11y agoExcellent!
- mjevans 11y agoI like how busybox cat does it, with a do while loop: https://git.busybox.net/busybox/tree/coreutils/cat.c https://git.busybox.net/busybox/tree/coreutils/cat.c
- throwaway999888 11y ago> That is asinine. Why would a program be called ‘cat’ if it can’t concatenate multiple files? Because he only thinks it's the "echo file to terminal" command. The main use of cat was mentioned in the Programming in the UNIX environment article. > The fact that cat will also print on the terminal is a special case. Perhaps surprisingly, in practice it turns out that the special case is the main use of the program. [...] But what about -v? That prints non-printing characters in a visible representation. Making strange characters visible is a genuinely new function, for which no existing program is suitable. [...] The answer is ‘‘No.’’ Such a modification confuses what cat ’s job is concatenating files with what it happens to do in a common special case - showing a file on the terminal. http://harmful.cat-v.org/cat-v/unix_prog_design.pdf http://harmful.cat-v.org/cat-v/unix_prog_design.pdf
- mtdewcmu 11y agoLike a lot of people, he overuses cat when it's not needed. `cat FOO | more` is approximately equivalent to `more < FOO`, except the first one spawns an extra process for no reason.
- throwaway999888 11y ago> except the first one spawns an extra process for no reason. I wonder how many processes I could spin up in the time it would take for me to figure out "hmm, no, invoking that command would use one more process than necessary..." I don't give a hoot about that stuff when I'm doing stuff interactively. e.g. when using `more`.
- deleted 11y ago[deleted]
- throwaway999888 11y agoBTW, the authors effectively embraced having the functionality of using `cat` instead of < . > The use of cat to feed a single input file to a program has to some degree superseded the shell’s < operator, which illustrates that general-purpose constructs - like cat and pipes - are often more natural than convenient special-purpose ones.