Skip to content

Commit

Permalink
Enable quiet mode when not running in a terminal
Browse files Browse the repository at this point in the history
When piping output to another command or redirecting output to a file we don't
want our script to output any unnecessary information which may break the other
command.

https://stackoverflow.com/questions/911168/how-can-i-detect-if-my-shell-script-is-running-through-a-pipe
  • Loading branch information
rjw1 committed Feb 28, 2025
1 parent 4952b5d commit 1d6dc88
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions bin/dalmatian
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ then
fi

QUIET_MODE=0

# set quiet mode if not running in a terminal
# e.g when piping output to another command or redirecting output to a file
if [ ! -t 1 ]
then
QUIET_MODE=1
fi

for i in "${!COMMAND_ARGS[@]}"
do
if [ "${COMMAND_ARGS[i]}" == "-q" ]
Expand Down

0 comments on commit 1d6dc88

Please sign in to comment.