Skip to content

Instantly share code, notes, and snippets.

@notwa
Created October 24, 2020 01:46
Show Gist options
  • Save notwa/feaa9d7c86e3e718bbe16d9cddf971d0 to your computer and use it in GitHub Desktop.
Save notwa/feaa9d7c86e3e718bbe16d9cddf971d0 to your computer and use it in GitHub Desktop.
silence
#!/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
}
@notwa
Copy link
Author

notwa commented Sep 10, 2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment