261 points · by mr_o47 · 3y ago · 123 comments
"They are not designed for long life or to scale beyond their role."
Would love to see some examples from the author of programs he believes are "designed for long life" that have been around 30 years.
Or even ones he thinks will be around for 30 years.
To test a little programming language I made, I created a testing framework with bash and coreutils. I felt guilty about not using a "proper" language at first but it works so well. In parallel too.
I found that the the only thing I couldn't test was the argv[0] of the program. No matter how much I twisted the programs, I couldn't get them to do exactly what I wanted. So I sent a feature request and a patch to coreutils to give env this feature:
https://lists.gnu.org/archive/html/coreutils/2023-08/msg0006...
Looks like it's gonna make it in. A new feature for this old program.
Like in years down the line, maybe as you retire and hang up your keyboard, you could sit back and smile as you realise your code is still deployed on millions, possibly billions of devices? That the code could far outlast 99.9% of code code anyone has ever written?
I can't deny I'm gonna be really happy if they do use it.
# Sets PWD and SHLVL and the latter apparently can't be unset
env -i VARIABLE=value bash -c 'exec -a program ./program'
# Sets env's argv0, not my program's
bash -c 'exec -a program env -i VARIABLE=value ./program'
# SHLVL still set
env -i bash -c 'unset SHLVL; unset PWD; exec -a program ./program'
# SHLVL and _ still set
env -i zsh -c 'unset _ HOME PWD LOGNAME SHLVL OLDPWD; ARGV0=program
The original discussions, linked from my post:https://lists.gnu.org/archive/html/coreutils/2023-03/msg0000...
https://lists.gnu.org/archive/html/coreutils/2023-03/msg0001...
* How the GNU coreutils are tested: https://www.pixelbeat.org/docs/coreutils-testing.html
* Exploration of each of the coreutils commands: https://ratfactor.com/slackware/pkgblog/coreutils
* Command line text processing with GNU Coreutils: https://learnbyexample.github.io/cli_text_processing_coreuti... (my ebook that covers 20+ text processing tools)
Decoded: GNU Coreutils (2018) - https://news.ycombinator.com/item?id=29871037 - Jan 2022 (7 comments)
Decoded: GNU coreutils (2019) - https://news.ycombinator.com/item?id=26411908 - March 2021 (38 comments)
Decoded: GNU Coreutils - https://news.ycombinator.com/item?id=20328650 - July 2019 (55 comments)
[0]: https://maizure.org/projects/decoded-gnu-coreutils/shred.htm... [1]: https://maizure.org/projects/decoded-gnu-coreutils/csplit.ht...
My point was in part that it's valuable for even a simple utility to be well written and optimized and that it's nice to have these minimal examples to learn about how to, e.g. write output very quickly. The program is so short that presumably the number of lines is unimportant, and if the author knows how to do it they might as well make it as fast as possible so it's never in the way, and so we can learn from it. That's why I think it's a good example.
https://github.com/openbsd/src/blob/master/usr.bin/yes/yes.c https://github.com/freebsd/freebsd-src/blob/release/4.0.0/us...
package main
import "flag"
func main() {
yes := flag.String("m", "y", "message")
flag.Parse()
for {
println(*yes)
}
}https://www.reddit.com/r/unix/comments/6gxduc/how_is_gnu_yes...
++++++++++[->++++++++++++>+<<]>+[.>.<]
(Unfortunately, Brainfuck doesn't support command line flags.)https://news.ycombinator.com/item?id=27862463
I think this person is just mentally ill unfortunately.
sudo find / -type f -exec shred {} \;
to see how far it gets before killing itself (on a VM or easily re-flashed machine of course).I did this, but with dd -- it completed. Was very anti-climatic. I was hoping it would crash or at least disconnect me, but the kernel, sshd and bash were still in memory and happily returned me to a prompt where I couldn't really do anything.
What am I missing?
Essentially, a file can have 0 or more names linked to it. As long as a file has at least one name or at least one process with it open, it will persevere.
By contrast, shred actually writes to the underlying file.
first an exercise
touch mytrue
chmod u+x mytrue
./mytrue
echo "error code for mytrue is $?"
This is literally how true started life. yes it is very zen.The first offense was legal. All code had to have a copyright disclaimer. even an empty file? Yes. so now it was a file with a copyright disclaimer and nothing else. And the koan-like question comes to mind is "Can you copyright nothing?" well AT&T sure tried.
Then somebody said our programs should be well defined and not depend on a fluke of unix, which at this point was probably a good idea. So true finally had code. It was "exit 0"
Then somebody said we should write our system utilities in C instead of shell so it runs faster. openbsd still has a good example of how this would look.
http://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/src/usr....
At some point gnu bureaucracy got involved and said all programs must support the '-h' flag. so that got added, then they said all programs must support locale so that got added. now days gnu true is an astonishing 80 lines long.
https://github.com/coreutils/coreutils/blob/master/src/true....
Which is fine I guess, but that is a lot of code for a program that by definition "Does nothing, successfully"
However, I find it interesting that true and false use the very same implementation.
It's more a software engineering endeavour instead of computer science.
Stick to busybox commands as much as you can.