From c3619ba6cf2e8f9dc4ba9961bb88c35f2b77c372 Mon Sep 17 00:00:00 2001 From: nnyyxxxx Date: Fri, 8 Nov 2024 21:43:28 -0500 Subject: [PATCH 1/2] check all commands before returning failure status --- core/tabs/common-script-test.sh | 17 +++++++++++++++++ core/tabs/common-script.sh | 11 ++++++----- 2 files changed, 23 insertions(+), 5 deletions(-) create mode 100755 core/tabs/common-script-test.sh diff --git a/core/tabs/common-script-test.sh b/core/tabs/common-script-test.sh new file mode 100755 index 000000000..2ac5639cd --- /dev/null +++ b/core/tabs/common-script-test.sh @@ -0,0 +1,17 @@ +#!/bin/sh -e + +. ./common-script.sh + +command_exists ls pwd +[ $? -eq 0 ] || echo "FAIL: existing commands test" + +command_exists nonexistentcmd1 +[ $? -eq 1 ] || echo "FAIL: non-existing command test" + +command_exists ls nonexistentcmd2 pwd +[ $? -eq 1 ] || echo "FAIL: mixed commands test" + +command_exists nonexistentcmd3 nonexistentcmd4 +[ $? -eq 1 ] || echo "FAIL: multiple non-existing test" + +echo "All tests completed" diff --git a/core/tabs/common-script.sh b/core/tabs/common-script.sh index f8188ac32..8bc1d14c5 100644 --- a/core/tabs/common-script.sh +++ b/core/tabs/common-script.sh @@ -9,11 +9,12 @@ CYAN='\033[36m' GREEN='\033[32m' command_exists() { -for cmd in "$@"; do - export PATH="$HOME/.local/share/flatpak/exports/bin:/var/lib/flatpak/exports/bin:$PATH" - command -v "$cmd" >/dev/null 2>&1 || return 1 -done -return 0 + failed=0 + for cmd in "$@"; do + export PATH="$HOME/.local/share/flatpak/exports/bin:/var/lib/flatpak/exports/bin:$PATH" + command -v "$cmd" >/dev/null 2>&1 || failed=1 + done + return $failed } checkFlatpak() { From e7b0803a95d6b246bbe0cc5ebe20205aa3db4aea Mon Sep 17 00:00:00 2001 From: nnyyxxxx Date: Fri, 8 Nov 2024 21:43:43 -0500 Subject: [PATCH 2/2] oopsy --- core/tabs/common-script-test.sh | 17 ----------------- 1 file changed, 17 deletions(-) delete mode 100755 core/tabs/common-script-test.sh diff --git a/core/tabs/common-script-test.sh b/core/tabs/common-script-test.sh deleted file mode 100755 index 2ac5639cd..000000000 --- a/core/tabs/common-script-test.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/sh -e - -. ./common-script.sh - -command_exists ls pwd -[ $? -eq 0 ] || echo "FAIL: existing commands test" - -command_exists nonexistentcmd1 -[ $? -eq 1 ] || echo "FAIL: non-existing command test" - -command_exists ls nonexistentcmd2 pwd -[ $? -eq 1 ] || echo "FAIL: mixed commands test" - -command_exists nonexistentcmd3 nonexistentcmd4 -[ $? -eq 1 ] || echo "FAIL: multiple non-existing test" - -echo "All tests completed"