From ad21fd30f3dfc1260b55e696da87c3d1c2d71712 Mon Sep 17 00:00:00 2001 From: Christoph Date: Mon, 19 Dec 2022 00:36:31 +0100 Subject: [PATCH] Print conficting script warning only if running in a terminal. --- snippets/base_script.sh | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/snippets/base_script.sh b/snippets/base_script.sh index 75b91ad..ee8729d 100755 --- a/snippets/base_script.sh +++ b/snippets/base_script.sh @@ -115,6 +115,14 @@ warn (){ echo "" } +warn_only_terminal () { + if $terminal ; then + echo "" + echo -e "\t[ \033[33m\033[1mWarning\033[m ]: $*" + echo "" + fi +} + info (){ echo "" if $terminal ; then @@ -577,11 +585,9 @@ if [[ ${#CONFLICTING_SCRIPTS} -gt 0 ]] ; then if $_stop_running ; then - echo "" - echo "[ Error ]: The \"${_script_name}\" script is currently running, but it conflicts with this script." - echo "" - echo " Exiting now.." - echo "" + warn_only_terminal "\033[1m${_script_name}\033[m is currently running, but it conflicts with this script. + + Exiting now.." clean_up 1