logoalt Hacker News

rootnod3yesterday at 11:45 PM2 repliesview on HN

And some code is absolutely unnecessary. Look at the yes command. GNU version is optimized to death for no reason at all[1].

OpenBSD's version is as simple as it gets[2].

[1]: https://github.com/coreutils/coreutils/blob/master/src/yes.c [2]: https://github.com/openbsd/src/blob/master/usr.bin/yes/yes.c


Replies

collinfunktoday at 5:00 PM

The others and I, working on GNU coreutils, frequently use 'yes' to generate a bunch of garbage input for testing programs. It is nice that it can do so quickly.

ptxtoday at 11:10 AM

Just as another point of comparison, FreeBSD's version seems somewhere in-between. It also enables a Capsicum sandbox before processing any data, akin to what the OpenBSD version does with pledge.

[1] https://github.com/freebsd/freebsd-src/blob/main/usr.bin/yes...

show 2 replies