# Pastebin BpumQpEw #!/bin/bash ... # Determine platform & init vars cumulative_RC=0 OS=$(uname) if [[ $OS =~ Darwin ]]; then # MacOS(X) systemctl="launchctl" sudo="sudo" ln="ln -nfs" gsed="gsed" # installed via (home)brew shellcheck_dir="utilities/shellcheck/macos/" elif [[ $OS =~ CYGWIN ]]; then systemctl="sc.exe" sudo="" ln="winln -fs" gsed="sed" shellcheck_dir="utilities/shellcheck/windows/" elif [[ $OS =~ Linux ]]; then systemctl="sytemctl" sudo="sudo" ln="ln -nfs" gsed="sed" shellcheck_dir="utilities/shellcheck/linux/" else echo 'x Error, unknown platform "'$OS'", only MacOS (Darwin), Windows (via CYGWIN), and Linux currently supported!' exit 2 fi; files_to_check=$(git status --porcelain | egrep '^M.*' | egrep '\.*sh$' | awk '{ print $2}') for i in "${files_to_check[@]}"; do "${shellcheck_dir}"/shellcheck -S error "${i}" cumulative_RC=$((RC+$?)) done; if [[ "${cumulative_RC}" -ne 0 ]]; then echo 'x Error, one or more files failed shellcheck! See output above. Failing commit with cumulative_RC = '${cumulative_RC} exit "${cumulative_RC}" fi;