Skip to content

Instantly share code, notes, and snippets.

@dduan

dduan/quiet.sh

Last active Jan 7, 2018
Embed
What would you like to do?
Run any command and suppress its output to stdin and stderr, unless it returns an error code.
#!/usr/bin/env bash
# Run any command and suppress its output to stdin and stderr, unless it returns an error code.
OUTPUT=$(${@:1} 2>&1)
if [ $? -eq 0 ]; then
exit
fi
OLDLFS=$LFS
IFS=$'\n'
for l in $OUTPUT; do
echo $l;
done
LFS=$OLDLFS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.