From 32a579313971f24f4ebea8baa7df25bb145c11a4 Mon Sep 17 00:00:00 2001 From: ckie Date: Thu, 17 Nov 2022 08:09:12 +0200 Subject: [PATCH] mount-file.bash: be quieter when debugging is off --- mount-file.bash | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/mount-file.bash b/mount-file.bash index 31997ba..6202d07 100755 --- a/mount-file.bash +++ b/mount-file.bash @@ -19,14 +19,19 @@ mountPoint="$1" targetFile="$2" debug="$3" +trace() { + if (( "$debug" )); then + echo "$@" + fi +} if (( "$debug" )); then set -o xtrace fi if [[ -L "$mountPoint" && $(readlink -f "$mountPoint") == "$targetFile" ]]; then - echo "$mountPoint already links to $targetFile, ignoring" + trace "$mountPoint already links to $targetFile, ignoring" elif mount | grep -F "$mountPoint"' ' >/dev/null && ! mount | grep -F "$mountPoint"/ >/dev/null; then - echo "mount already exists at $mountPoint, ignoring" + trace "mount already exists at $mountPoint, ignoring" elif [[ -e "$mountPoint" ]]; then echo "A file already exists at $mountPoint!" >&2 exit 1