Created
October 24, 2020 01:46
-
-
Save notwa/feaa9d7c86e3e718bbe16d9cddf971d0 to your computer and use it in GitHub Desktop.
silence
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ash | |
echo2() { | |
local IFS=" " | |
printf "%s\n" "$*" >&2 | |
} | |
note() { | |
local IFS=" " | |
printf "\033[1m%s\033[0m\n" "$*" >&2 | |
} | |
stfu() { | |
local ret=0 | |
"$@" > .stdout 2> .stderr || ret=$? | |
if test "$ret" -ne 0; then | |
printf "command failed with exit status %s:\n" "$ret" >&2 | |
echo2 "$@" | |
echo2 | |
note '$ tail .stdout' | |
tail -n 20 .stdout >&2 | |
echo2 | |
note '$ tail .stderr' | |
tail -n 20 .stderr >&2 | |
return "$ret" | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
overengineered vesion: https://github.com/notwa/rc/blob/master/sh/stfu