cosmopolitan/build/getlogfmt
Justine Tunney f213556366 Add binfmt_misc workaround detector to builds
This is a recently introduced Linux Kernel feature that gives people
like Debian package mantainers the power to arbitrarily redefine how
executables are interpreted by the kernel. If your system gets tuned
this way and you're not able to disable it, then you need to restore
default behavior for the APE MZqFpD prefix as follows:

    sudo sh -c "echo ':APE:M::MZqFpD::/bin/sh:' >/proc/sys/fs/binfmt_misc/register"

This prefix will cover all .com executables built with this tooling.
Please don't run the above command unless you're certain you need it.
See #2 for additional context.
2020-08-31 20:09:23 -07:00

33 lines
829 B
Bash
Executable file

#!/usr/bin/env bash
#-*-mode:sh;indent-tabs-mode:nil;tab-width:2;coding:utf-8-*-┐
#───vi: set net ft=sh ts=2 sts=2 fenc=utf-8 :vi─────────────┘
#
# OVERVIEW
#
# Printf Logger Initializer
#
# DESCRIPTION
#
# This program is invoked once by build/definitions.mk to choose the
# most appropriate format string when logging command invocations.
if [ "$SILENT" = "0" ]; then
printf "''"
else
W1=15
if [ "$TERM" = "dumb" ]; then # e.g. emacs' dismal tty
if [ "$COLUMNS" = "" ]; then
if TPUT=$(command -v tput); then
COLUMNS=$("$TPUT" cols)
else
COLUMNS=80
fi
fi
COLUMNS=$((COLUMNS - 1))
W2=$((COLUMNS - W1))
printf '%%-%ds%%-%ds\\r' "$W1" "$W2"
else
echo ♥cosmo >&2
printf '\\033[F\\033[K%%-%ds%%s\\r\\n' "$W1"
fi
fi