Never read the source code of your heroes /hj

Follow

@wolf480pl As far as heroes go, I have only read the source code of Don Knuth, and I must say that, while I found it a bit weird in parts, it was definitely quality stuff.

@josemanuel I should've said "don't read the source code of a program you want to use, because you'll likely no longer want to use it"

@wolf480pl @josemanuel >Read the source code of the GNU package.
>Want to use it more.

@Suiseiseki @josemanuel
have you tried reading the source code of /bin/true from GNU coreutils?

@wolf480pl @josemanuel Every line was beautiful, beautifully implementing --help and --version, in multiple languages like so;
true (GNU coreutils) 9.7
パッケージ作成者: Gentoo (9.7 (p0))
Copyright (C) 2025 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

作者 Jim Meyering

@Suiseiseki @josemanuel perfection is when there is no line that ciuld be removed.

POSIX does not require /bin/true to have --help and --version. Arguably, it is against POSIX for those programs to output anything at all. And it is completely unnecessary. A program like /bin/true could be implemented in 3 lines of code. It could have 3 assembly instructions. Its code could be smaller than the ELF header.

And yet, it is bloated with legalese.

@wolf480pl @josemanuel Perfection is when the program has full freedom and the user can pass --help or --version and see how to use the program and also the license.

GNU does not follow proprietary specifications like POSIX and even if the fine GNU functionality breaks POSIX, it is done, no matter how hard the resulting seething over the GNU/Freedom.

The number of instructions executed when not called with --help or --version is very small.

Advising the user that it is free software under a free license is not legalese.


GNU true and GNU false are really just a fallback if such commands are not a built-in.

For bash, there is already `help true` and `help false` to assist the user as to how to use the built-in;
help true
true: true
Return a successful result.

Exit Status:
Always succeeds.
help false
false: false
Return an unsuccessful result.

Exit Status:
Always fails.
LANG=ja_JP.UTF-8 help true
true: true
結果として成功を返します。

終了ステータス:
常に成功です。
LANG=ja_JP.UTF-8 help false
false: false
結果として失敗を返します。

終了ステータス:
常に失敗です。
@wolf480pl@mstdn.io @josemanuel@qoto.org @Suiseiseki@freesoftwareextremist.com I enjoy freedom, and I'm grateful for the work of GNU volunteers, but the number of instructions executed to run true is 146,925 instructions, doing 39 syscalls. To be fair, a lot of this is due to dynamic linking and glibc C runtime initialization, which is standard on most GNU systems.

@rozenglass @wolf480pl @josemanuel If performance is a concern, just use the bash built-in;
time true
real 0m0.000s
user 0m0.000s
sys 0m0.000s
Sign in to participate in the conversation
Qoto Mastodon

QOTO: Question Others to Teach Ourselves
An inclusive, Academic Freedom, instance
All cultures welcome.
Hate speech and harassment strictly forbidden.