From 1d6dc882b051ae9bc77dd89c9ee80731bff0f955 Mon Sep 17 00:00:00 2001 From: bob walker Date: Fri, 28 Feb 2025 12:07:36 +0000 Subject: [PATCH] Enable quiet mode when not running in a terminal 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 --- bin/dalmatian | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/bin/dalmatian b/bin/dalmatian index adc80d5..171ba25 100755 --- a/bin/dalmatian +++ b/bin/dalmatian @@ -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" ]