Hacker News new | ask | show | jobs
by 0xbadcafebee 1383 days ago
If we had a Busybox for every platform, and you compiled your app for every platform, you could bundle it all as one compressed shell script. Not as cool as one binary that works everywhere, but much simpler.

  #!/usr/bin/env sh
  set -eu
  FILE="${OS:-$(uname -s)}/${ARCH:-$(uname -p)}/${MACH:-$(uname -m)}/exe"
  unzip -d "${TMPDIR:-/tmp}" -X -b -o "$0" "$FILE"
  [ $? -gt 1 ] || exec "${TMPDIR:-/tmp}/$FILE"
  echo "$0: Error: could not execute '$FILE'" ; exit 126
  ########################################################
  # After here the Zip file is concatenated into the file