From f615dc5486199971dae940575f6b2d616c85b177 Mon Sep 17 00:00:00 2001 From: ludeeus Date: Sat, 30 May 2020 00:06:39 +0200 Subject: [PATCH] restructure --- runaction.sh | 77 +++++++++++++++++++++++++++++++--------------------- 1 file changed, 46 insertions(+), 31 deletions(-) mode change 100644 => 100755 runaction.sh diff --git a/runaction.sh b/runaction.sh old mode 100644 new mode 100755 index 2516f08..59dee08 --- a/runaction.sh +++ b/runaction.sh @@ -1,48 +1,63 @@ -#!/bin/sh +#!/bin/bash cd "$GITHUB_WORKSPACE" || exit 1 +declare err +declare -a filepaths +declare -a tmp + err=0 -find . '(' -name '*.bash' \ - -o -path '*/.bash*' -o -path '*/bash*' \ - \ - -o -name '*.ksh' \ - -o -name 'ksh*' \ - -o -path '*/.ksh*' -o -path '*/ksh*' \ - -o -name 'suid_profile' \ - \ - -o -name '*.zsh' \ - -o -name '.zlogin*' -o -name 'zlogin*' \ - -o -name '.zlogout*' -o -name 'zlogout*' \ - -o -name '.zprofile*' -o -name 'zprofile*' \ - -o -path '*/.zsh*' -o -path '*/zsh*' \ - \ - -o -name '*.sh' \ - -o -path '*/.profile*' -o -path '*/profile*' \ - -o -path '*/.shlib*' -o -path '*/shlib*' \ - ')' -exec shellcheck {} + || err=1 +readarray -d '' filepaths < <(find . '(' \ + \ + -name '*.bash' \ + -o -path '*/.bash*' \ + -o -path '*/bash*' \ + -o -name '*.ksh' \ + -o -name 'ksh*' \ + -o -path '*/.ksh*' \ + -o -path '*/ksh*' \ + -o -name 'suid_profile' \ + -o -name '*.zsh' \ + -o -name '.zlogin*' \ + -o -name 'zlogin*' \ + -o -name '.zlogout*' \ + -o -name 'zlogout*' \ + -o -name '.zprofile*' \ + -o -name 'zprofile*' \ + -o -path '*/.zsh*' \ + -o -path '*/zsh*' \ + -o -name '*.sh' \ + -o -path '*/.profile*' \ + -o -path '*/profile*' \ + -o -path '*/.shlib*' \ + -o -path '*/shlib*' \ + ')'\ + \ + -print0) -# shellcheck disable=SC2016 -find . -type f ! -name '*.*' -perm /111 -exec sh -c ' - for f - do - head -n1 "$f" | grep -Eqs "^#! */[^ ]*/[abkz]*sh" || continue - shellcheck "$f" || err=$? - done - exit $err - ' _ {} + || err=1 + +readarray -d '' tmp < <(find . -type f ! -name '*.sh' -perm /111 -print0) +for file in "${tmp[@]}"; do + head -n1 "$file" | grep -Eqs "^#! */[^ ]*/[abkz]*sh" || continue + filepaths+=("$file") +done if find . -path '*bin/*/*' -type f -perm /111 -print | grep . then - echo >&2 "WARNING: subdirectories of bin directories are not usable via PATH" + echo >&2 "::warning:: subdirectories of bin directories are not usable via PATH" fi if find . -path '*bin/*' -name '*.*' -type f -perm /111 -perm /444 -print | grep . then - echo >&2 "WARNING: programs in PATH should not have a filename suffix" + echo >&2 "::warning:: programs in PATH should not have a filename suffix" fi -exit "$err" +for file in "${filepaths[@]}"; do + echo "::debug:: Checking $file" + shellcheck "$file" || err=$? +done + +exit "$err" \ No newline at end of file