Skip to content

Commit 1f77105

Browse files
committed
Use enhanced Bash-style conditionals
1 parent c6fe556 commit 1f77105

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

bin/check-file-permissions

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env sh
1+
#!/usr/bin/env bash
22
set -eu
33

44
FILES_WITH_WRONG_PERMISSIONS=$(
@@ -12,28 +12,28 @@ BIN_FILES_WITH_WRONG_PERMISSIONS=$(
1212
| sort -fh
1313
)
1414

15-
if [ -n "$FILES_WITH_WRONG_PERMISSIONS" ]; then
16-
printf '\033[31mFAIL\033[0m Non-executable files with +x permissions were detected!\n'
17-
[ -z "${GITHUB_ACTIONS+x}" ] || echo '::group::Non-executable files'
15+
if [[ -n "$FILES_WITH_WRONG_PERMISSIONS" ]]; then
16+
printf '\033[41m FAIL \033[0m Non-executable files with +x permissions were detected!\n'
17+
[[ -z "${GITHUB_ACTIONS+x}" ]] || echo '::group::Non-executable files'
1818
echo "$FILES_WITH_WRONG_PERMISSIONS"
1919
echo ''
2020
echo "$FILES_WITH_WRONG_PERMISSIONS" | awk '{print $4}' | xargs -n1 printf 'Please run "\033[32msudo chmod\033[0m -x %s".\n'
21-
[ -z "${GITHUB_ACTIONS+x}" ] || echo '::endgroup::'
21+
[[ -z "${GITHUB_ACTIONS+x}" ]] || echo '::endgroup::'
2222
fi
2323

24-
if [ -n "$BIN_FILES_WITH_WRONG_PERMISSIONS" ]; then
25-
printf '\033[31mFAIL\033[0m Executable files with -x permissions were detected!\n'
26-
[ -z "${GITHUB_ACTIONS+x}" ] || echo '::group::Executable files'
24+
if [[ -n "$BIN_FILES_WITH_WRONG_PERMISSIONS" ]]; then
25+
printf '\033[41m FAIL \033[0m Executable files with -x permissions were detected!\n'
26+
[[ -z "${GITHUB_ACTIONS+x}" ]] || echo '::group::Executable files'
2727
echo "$BIN_FILES_WITH_WRONG_PERMISSIONS"
2828
echo ''
2929
echo $BIN_FILES_WITH_WRONG_PERMISSIONS | awk '{print $4}' | xargs -n1 printf 'Please run "\033[32msudo chmod\033[0m +x %s".\n'
30-
[ -z "${GITHUB_ACTIONS+x}" ] || echo '::endgroup::'
30+
[[ -z "${GITHUB_ACTIONS+x}" ]] || echo '::endgroup::'
3131
fi
3232

33-
if [ -n "$FILES_WITH_WRONG_PERMISSIONS" ]; then
33+
if [[ -n "$FILES_WITH_WRONG_PERMISSIONS" ]]; then
3434
exit 3
35-
elif [ -n "$BIN_FILES_WITH_WRONG_PERMISSIONS" ]; then
35+
elif [[ -n "$BIN_FILES_WITH_WRONG_PERMISSIONS" ]]; then
3636
exit 4
3737
fi
3838

39-
printf '\033[32mOK\033[0m No wrong permissions were detected.\n'
39+
printf '\033[42m OK \033[0m No wrong permissions were detected.\n'

0 commit comments

Comments
 (0)