From 703be55cdf1882b985067c547a148455c2a5530c Mon Sep 17 00:00:00 2001 From: Hari Sekhon Date: Wed, 14 Jun 2023 23:16:28 +0100 Subject: [PATCH] updated check_non_executable_scripts.sh --- checks/check_non_executable_scripts.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/checks/check_non_executable_scripts.sh b/checks/check_non_executable_scripts.sh index a08f40e7..5c733a83 100755 --- a/checks/check_non_executable_scripts.sh +++ b/checks/check_non_executable_scripts.sh @@ -24,6 +24,17 @@ srcdir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" section "Finding Non Executable Scripts" +# These shouldn't be executable even if they have #! lines for syntax reasons +exceptions=" +.env +.envrc +" +exceptions_regex="" +for exception in $exceptions; do + exceptions_regex="$exceptions_regex|$exception" +done +exceptions_regex="(${exceptions_regex#|})$" + #filter_is_git_committed(){ # while read -r filename; do # pushd "$(dirname "$filename")" &>/dev/null @@ -49,6 +60,7 @@ set +o pipefail non_executable_scripts="$( eval find "${1:-$PWD}" -maxdepth 2 -type f -not -perm -u+x | xargs grep -l '^#!' | + grep -Ev "$exceptions_regex" | filter_is_shebang | tee /dev/stderr )"