From e9a1903fff09ba2786106233def47fdc5006d885 Mon Sep 17 00:00:00 2001 From: "John Paul E. Balandan, CPA" Date: Wed, 7 Aug 2024 12:00:52 +0800 Subject: [PATCH] Use enhanced Bash-style conditionals --- bin/check-file-permissions | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/bin/check-file-permissions b/bin/check-file-permissions index 27ccbb6..4b40f4f 100755 --- a/bin/check-file-permissions +++ b/bin/check-file-permissions @@ -12,28 +12,28 @@ BIN_FILES_WITH_WRONG_PERMISSIONS=$( | sort -fh ) -if [ -n "$FILES_WITH_WRONG_PERMISSIONS" ]; then - printf '\033[31mFAIL\033[0m Non-executable files with +x permissions were detected!\n' - [ -z "${GITHUB_ACTIONS+x}" ] || echo '::group::Non-executable files' +if [[ -n "$FILES_WITH_WRONG_PERMISSIONS" ]]; then + printf '\033[41m FAIL \033[0m Non-executable files with +x permissions were detected!\n' + [[ -z "${GITHUB_ACTIONS+x}" ]] || echo '::group::Non-executable files' echo "$FILES_WITH_WRONG_PERMISSIONS" echo '' echo "$FILES_WITH_WRONG_PERMISSIONS" | awk '{print $4}' | xargs -n1 printf 'Please run "\033[32msudo chmod\033[0m -x %s".\n' - [ -z "${GITHUB_ACTIONS+x}" ] || echo '::endgroup::' + [[ -z "${GITHUB_ACTIONS+x}" ]] || echo '::endgroup::' fi -if [ -n "$BIN_FILES_WITH_WRONG_PERMISSIONS" ]; then - printf '\033[31mFAIL\033[0m Executable files with -x permissions were detected!\n' - [ -z "${GITHUB_ACTIONS+x}" ] || echo '::group::Executable files' +if [[ -n "$BIN_FILES_WITH_WRONG_PERMISSIONS" ]]; then + printf '\033[41m FAIL \033[0m Executable files with -x permissions were detected!\n' + [[ -z "${GITHUB_ACTIONS+x}" ]] || echo '::group::Executable files' echo "$BIN_FILES_WITH_WRONG_PERMISSIONS" echo '' echo $BIN_FILES_WITH_WRONG_PERMISSIONS | awk '{print $4}' | xargs -n1 printf 'Please run "\033[32msudo chmod\033[0m +x %s".\n' - [ -z "${GITHUB_ACTIONS+x}" ] || echo '::endgroup::' + [[ -z "${GITHUB_ACTIONS+x}" ]] || echo '::endgroup::' fi -if [ -n "$FILES_WITH_WRONG_PERMISSIONS" ]; then +if [[ -n "$FILES_WITH_WRONG_PERMISSIONS" ]]; then exit 3 -elif [ -n "$BIN_FILES_WITH_WRONG_PERMISSIONS" ]; then +elif [[ -n "$BIN_FILES_WITH_WRONG_PERMISSIONS" ]]; then exit 4 fi -printf '\033[32mOK\033[0m No wrong permissions were detected.\n' +printf '\033[42m OK \033[0m No wrong permissions were detected.\n'