5 ms·
Just replying to point out that the grayed out comment above is the correct one. There is ugliness in coreutils, but it mature, functional, proven ugliness. A
by cplease 11y ago
Just replying to point out that the grayed out comment above is the correct one.
There is ugliness in coreutils, but it mature, functional, proven ugliness. A lot of it is even there for a reason.
It's not difficult to make an elegant toy in isolation.
- setra 11y agocheckout the different implementations of echo across various operating systems: "https://gist.github.com/dchest/1091803" https://gist.github.com/dchest/1091803".
- 2trill2spill 11y agoThat link is not working for me, Github is throwing a 404.
- cjs2 11y agoThe link has an extraneous `"` character at the end. It works fine if you remove it.
- setra 11y agoBrowser seem to include the end quote when clicked. It mush be removed for the url to work.
- vinkelhake 11y agoI've used the -e option in GNU's echo many times. The various other versions are strictly less useful to me. Does the option really belong in echo? Who knows, but it's certainly been useful to me. UNIX fifth edition goes for absolute minimalism. Echo in Plan 9 is apparently used enough that it's worthwhile to optimize the number of times write is called. FreeBSD echo looks like someone just learned about writev. OpenBSD's seem like the sanest of the minimalists. What's the takeaway for you?
- laumars 11y agoI've used -e on GNU's `echo` quite a bit as well. But FreeBSD also supports `printf` (as does Linux by the way), so it's not a great inconvenience the missing -e flag on FreeBSD's `echo`. $ printf "This\tis an\nexample\n" This is an example You can also use the usual C-style printf parameters as well: $ printf "This is %-20s example\n" another This is another example
- JdeBP 11y ago> What's the takeaway for you? For many people, from the writers of the Single Unix Specification to the Debian Policy people, the take-away was and is use printf, for nigh on 20 years now. * https://www.debian.org/doc/manuals/debian-reference/ch12.en.html#_posix_shell_compatibility https://www.debian.org/doc/manuals/debian-reference/ch12.en.... * http://pubs.opengroup.org/onlinepubs/7908799/xcu/echo.html#tag_001_014_525 http://pubs.opengroup.org/onlinepubs/7908799/xcu/echo.html#t... * https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=490605 https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=490605 * http://www.in-ulm.de/~mascheck/various/echo+printf/ http://www.in-ulm.de/~mascheck/various/echo+printf/ * http://mywiki.wooledge.org/Bashism#Builtins http://mywiki.wooledge.org/Bashism#Builtins * https://wiki.ubuntu.com/DashAsBinSh#echo https://wiki.ubuntu.com/DashAsBinSh#echo * https://lwn.net/Articles/346028/ https://lwn.net/Articles/346028/
- cplease 11y agoDo you even know what coreutils is? It is not openbsdutils. It is not plan9utils. It is not even linuxutils. It builds and runs on virtually every deployed vaguely POSIX-ish environment and then some. Can I take the OpenBSD userland and untar, configure, build and run in cygwin? Nope. You have proven my point. Nobody uses the little SYS V version. One hint as to why the GNU version is so "long" and "messy": /* System V machines already have a /bin/sh with a v9 behavior. Use the identical behavior for these machines so that the existing system shell scripts won't barf. */ bool do_v9 = DEFAULT_ECHO_TO_XPG; It has to run in environments that others do not in order to provide full functionality, so it has to implement that functionality. And Unix Fifth Edition, imbued with the cleanliness of Ken Thompson's ghost? Yeah, that's lovely, but not only is it again, of limited utility and portability across idiosyncratic modern environments, but it's full of bugs dating to an era where simplicity was valued above handling all inputs. In 1983, crashing on a bad input wasn't even generally understood to BE a bug, much less extremely dangerous especially in core system utilities.
- kazinator 11y agoAs a result, the specification for echo is a ridiculous mess which deviates from the other POSIX utilities. It doesn't have the normal command argument handling, and also has implementation-defined behaviors. It's a good command to avoid in serious scripting, other than for outputting fixed, alphanumeric strings. That said, it's useful to have features like C escape sequences for control characters or arbitrary characters. That feature should be in the shell language. Someone needed it and hacked it into some version of echo. Others elsewhere didn't and so now it's implementation defined whether or not you get backslash processing.
- kazinator 11y agoTo delimit URL's, use square brackets: [https://gist.github.com/dchest/109180 https://gist.github.com/dchest/109180]. There is an RFC standard way of quoting URLs and addresses, namely angle brackets. HN doesn't implement it, though: <https://gist.github.com/dchest/109180> https://gist.github.com/dchest/109180>. See? The closing > is included in the URL, stupidly. The convention first appeared in [https://www.ietf.org/rfc/rfc1738.txt https://www.ietf.org/rfc/rfc1738.txt] in 1995, with Tim Berners Lee the top author.