1. 52
  1.  

  2. 8

    Because the GNU coreutils are bloated as hell. Just look at true.c from GNU coretuils compared to the suckless-implementation true.c in sbase.

    1. 8

      It is almost that exact question that started me down a path that (weeks later) led to writing the Teensy essay. But for me, the real answer to that question was when I finally managed to write a 45-byte true+false binary (at the top of https://www.muppetlabs.com/~breadbox/software/tiny/useless.html).

        1. 8

          The length and depth of the top answer made my day ツ.

          1. 4

            In some Unices, true is simply a shell script that does nothing. It could be the empty file, save for the comments at the top with copyright and licensing information.

            1. 1

              The bloat is indeed impressive.

              Even if trying hard to make small binaries, elf format itself forces some sizable bloat in.

              1. 7

                It doesn’t really matter as long as the results fit in a single sector of the disk (or a single unit of allocation for the file system). On Linux, I compiled the following code:

                extern void _exit(int);
                void _start(void)
                {
                  _exit(0);
                }
                

                using gcc -static -nostartfiles -o true true.c && strip true to get an executable size less than 512 bytes.

                1. 1

                  … on filesystems without tail packing, that is.

                  1. 2

                    Interesting. I did not know that. Thanks.

              2. 1

                IIRC, the first time the grew bigger than exit 0 and exit 1 was when they had to include the copyright in the shell script. I vaguely remember there was a blog post that explained how that even affected their performance since the shell now instead of evaluating one line had to read 30 or so lines before doing anything.

                1. 1
                  1. 1

                    FWIW Oil’s app bundle behaves like “true” and “false” just for kicks… Just like it behaves like “osh” and “oil”, in the style of busybox.

                    As the post mentions, true and false are shells builtins, so you don’t need the executables in shell scripts. But what are the chances that some external program calls os.system("true")? Almost none, but they need to be there.

                    So in theory on an Oil-based system you can just have symlinks to the Oil binary instead of another little hunk of C code that needs to be compiled.

                    1. 11

                      But what are the chances that some external program calls os.system("true")?

                      I have system users with /etc/passwd shells set to /bin/false and I’ve definitely had occasion to do things like PAGER=/bin/true git log .... Little stuff like that comes up surprisingly often

                      1. 1

                        It’s more common to use /usr/sbin/nologin for that.

                      2. 4

                        Use hard links instead of symlinks for even better minimization of disk usage.