1. 2

    I think this article misses the rather important section which could be relevant to the title saying “small CLI programs”: how can you transform that whole Common Lisp codebase into single, statically linked, standalone executable binary which could work on remote hosts being copied over SSH without gazillions of uneeded dependencies?

    1. 7

      how can you transform that whole Common Lisp codebase into single, statically linked, standalone executable binary which could work on remote hosts being copied over SSH without gazillions of uneeded dependencies?

      That’s… pretty much what it’s doing?

      sjl at alephnull in ~/src/dotfiles/lisp on default!?
      ><((°> touch batchcolor.lisp
      
      sjl at alephnull in ~/src/dotfiles/lisp on default!?
      ><((°> make
      mkdir -p bin
      ./build-binary batchcolor.lisp
      mv batchcolor bin/
      mkdir -p man/man1
      ./build-manual batchcolor.lisp
      mv batchcolor.1 man/man1/
      
      sjl at alephnull in ~/src/dotfiles/lisp on default!?
      ><((°> scp bin/batchcolor vm:batchcolor
      batchcolor                                   100%   42MB  59.4MB/s   00:00
      
      sjl at alephnull in ~/src/dotfiles/lisp on default!?
      ><((°> ssh vm
      
      vagrant@vm:~$ echo 'test 1234 test 1234 test 5678' | ./batchcolor '[0-9]+'
      test 1234 test 1234 test 5678
      
      vagrant@vm:~$ ldd batchcolor
              linux-vdso.so.1 (0x00007ffe7f369000)
              libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007ff4822da000)
              libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007ff4822b9000)
              libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007ff482136000)
              libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007ff481f75000)
              /lib64/ld-linux-x86-64.so.2 (0x00007ff482542000)
      

      It does depend on a few C libraries – if you want to remove even those you’ll need something like this.

      1. 3

        This article is not missing anything, it is what it is. If you did not find information you were looking for, then asking a question would be a polite way to get your answer.

        Also, if people cared so much about “single, statically linked, standalone executables” I would not have neither Python nor Perl installed on my system, and on the systems I’m connecting to over SSH. Or any other “dynamically linked” utilities, including SSH.

        1. 3

          Also, if people cared so much about “single, statically linked, standalone executables” I would not have neither Python nor Perl installed on my system, and on the systems I’m connecting to over SSH.

          I think the requirement to have a bajillion Python or Ruby libraries installed is why people have started to care about this sort of thing. In my experience, Go has been adopted for CLI tools partly as a rejection of this pattern since the Go compiler generates statically linked binaries (the fact that it handles cross-compilation fairly well is another benefit).

          1. 1

            Yes, “small python scripts” are basically useless if they require anything not in the stdlib, because then they’re not small anymore if you need dependencies (in this particular scenario) and that’s why most people still use shell scripts, or Go for statically compiled binaries.