Skip to content

Commit

Permalink
Use enhanced Bash-style conditionals
Browse files Browse the repository at this point in the history
  • Loading branch information
paulbalandan committed Aug 7, 2024
1 parent c6fe556 commit e9a1903
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions bin/check-file-permissions
Original file line number Diff line number Diff line change
Expand Up @@ -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'

0 comments on commit e9a1903

Please sign in to comment.