diff options
-rwxr-xr-x | bin/muffle | 11 |
1 files changed, 8 insertions, 3 deletions
@@ -4,7 +4,7 @@ set -eu usage() { cat <<-'EOF' Usage: - muffle [--] COMMAND... + muffle [-n] [--] COMMAND... muffle -h EOF } @@ -14,6 +14,7 @@ help() { Options: + -n invert when to do the muffling -h, --help show this message COMMAND the COMMAND to be muffled @@ -49,8 +50,12 @@ for flag in "$@"; do esac done -while getopts 'h' flag; do +INVERT=false +while getopts 'nh' flag; do case "$flag" in + (n) + INVERT=true + ;; (h) usage help @@ -80,7 +85,7 @@ echo 0 > "$STATUS_F" } 2>&1 | timed | pre err > "$ERR" STATUS="$(cat "$STATUS_F")" -if [ "$STATUS" != 0 ]; then +if [ "$INVERT" = false -a "$STATUS" != 0 ] || [ "$INVERT" = true -a "$STATUS" = 0 ]; then cat "$OUT" "$ERR" | sort -k2 | while read -r line; do if [ "$(printf '%s\n' "$line" | cut -d' ' -f1)" = 'out:' ]; then |