From 05e47c6564c0b279ad05f4a9432777152810c6be Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Thu, 4 May 2023 19:51:05 +0200 Subject: [PATCH] Add a script for checking whether a value is truthy --- scripts/Common/Config/UserProfile/install.sh | 5 +++-- scripts/Common/Scripts/is-truthy.sh | 10 ++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 scripts/Common/Scripts/is-truthy.sh diff --git a/scripts/Common/Config/UserProfile/install.sh b/scripts/Common/Config/UserProfile/install.sh index 57b724b6..c96698fb 100755 --- a/scripts/Common/Config/UserProfile/install.sh +++ b/scripts/Common/Config/UserProfile/install.sh @@ -3,8 +3,9 @@ NEXTCLOUD_DIR="${NEXTCLOUD_DIR:-Nextcloud}"; INSTALL_FONTS="${INSTALL_FONTS}"; dir="${BASH_SOURCE%/*}"; pushd "$dir" > /dev/null; +. "../../Scripts/is-truthy.sh"; -if [ ! -z "$INSTALL_FONTS" ] +if isTruthy "$INSTALL_FONTS" then # Microsoft Windows Fonts source "../Fonts/MicrosoftFonts/install.sh"; @@ -13,7 +14,7 @@ fi; # Sync clouds NEXTCLOUD_DIR="${NEXTCLOUD_DIR}" . "../rclone/InstallSync.sh" nextcloud "$NEXTCLOUD_DIR"; -if [ ! -z "$INSTALL_FONTS" ] +if isTruthy "$INSTALL_FONTS" then # Install fonts NEXTCLOUD_DIR="${NEXTCLOUD_DIR}" source "../Fonts/NerdFont/install.sh"; diff --git a/scripts/Common/Scripts/is-truthy.sh b/scripts/Common/Scripts/is-truthy.sh new file mode 100644 index 00000000..99158988 --- /dev/null +++ b/scripts/Common/Scripts/is-truthy.sh @@ -0,0 +1,10 @@ +function isTruthy() { + local value; + value="$1"; + + [ ! -z "$value" ] && + [ "$value" != "0" ] && + [ "$value" != "false" ] && + [ "$value" != "n" ] && + [ "$value" != "no" ]; +}