A digression on echo. - Other *nix-like OSes & POSIX related
Users browsing this thread: 4 Guest(s)
|
|||
After commenting on this thread I remembered a text on echo that Brian Kernighan and Rob Pike wrote in their book The UNIX Programming Environment called A digression on echo.
The single option -n is not like other options in other utilities. For example, while most utilities use getopt(3) to get the options, echo(1) should not use it, since a gotten option could be an argument to be echoed. See how OpenBSD implement echo, for example: Code: #include <stdio.h> Other than -n, modern echo implementations also add a new complexity: the C-like backslash sequences like '\n' and '\t'. Some echo implementations (such as OpenBSD's) just ignore them, but some (such as Bash built-in) don't. Here is another digression on echo about this very topic, by Doug Mcllroy, best known for proposing the UNIX pipelines and creating several UNIX tools: There is, however, another utility that does not print newlines when not asked for and that does interpret C-like backslash sequences: printf(1) PS: I don't know the right forum to post it. I posted it here in the Philosophy forum since I think that the question on bloatedness and feature creep are related to UNIX Philosophy. |
|||
|
|||
This seems to be one of the better examples on how Unix defaults to non-predictive behavior sometimes.
-- <mort> choosing a terrible license just to be spiteful towards others is possibly the most tux0r thing I've ever seen |
|||
|
|||
Good job digging up the history behind it. it was a really interesting read !
Reading the source code for echo under different implementations has been an exercise many people have taken to compare code complexity (obviously, GNU "wins" here). I personally only use "echo" to print out debug statements, or quickly output a variable name. For example, all my scripts feature this snippet: Code: usage() { Whenever I need to print out formatted stuff, printf(1) is my goto as it is much more convenient. |
|||
|
|||
(20-04-2020, 03:40 PM)z3bra Wrote: Reading the source code for echo under different implementations has been an exercise many people have taken to compare code complexity (obviously, GNU "wins" here). This comparison remembered me of this meme, based on longcat. |
|||
|
|||
I wonder how much of the GNU code is a try to circumvent the limitations imposed by its libc compared to Plan 9’s.
-- <mort> choosing a terrible license just to be spiteful towards others is possibly the most tux0r thing I've ever seen |
|||
|
|||
Hahaha awesome meme !
(20-04-2020, 04:33 PM)jkl Wrote: I wonder how much of the GNU code is a try to circumvent the limitations imposed by its libc compared to Plan 9’s. I think they're more trying to circumvent their own coding guidelines than the libc… Which is even more terrifying if you ask me. I mean. what the hell is this? or that? I'm speechless… |
|||
|
|||
"GNU's Not Unix. And here's how we mean that."
-- <mort> choosing a terrible license just to be spiteful towards others is possibly the most tux0r thing I've ever seen |
|||
|
|||
Reading the GNU coding standards was what convinced me to move back to OpenBSD, after having had to move back to Linux for certain software support which is no longer an issue. In particular, this paragraph:
Quote: For instance, Standard C says that nearly all extensions to C are It reads to me both as quite immature and as something of a "Microsoftian" attitude. Every time I see GNU code I find it offputting, and I wouldn't even really consider myself a UNIX purist. |
|||
|
|||
Another GNUism that turned out into a meme:
GNU true(1), an utility that is supposed to return zero (true), can return non-zero (false). That's because it does way more than return 0. Compare OpenBSD implementation of true(1) with GNU's. |
|||