From 72928bb96c0779f6ce05b5662835f6f1c4f1c1f0 Mon Sep 17 00:00:00 2001 From: Jan Macku Date: Tue, 3 Oct 2023 13:21:44 +0200 Subject: [PATCH 1/2] fix: drop support for DEBUG in grep It actually doesn't work as expected. Also the debug output is not very useful. --- src/functions.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/functions.sh b/src/functions.sh index 2bc439cf..5e960285 100644 --- a/src/functions.sh +++ b/src/functions.sh @@ -132,22 +132,22 @@ has_shebang () { local file="$1" # shell shebangs detection - if head -n1 "${file}" | grep ${RUNNER_DEBUG:+"--quiet"} -E '^\s*((#|!)|(#\s*!)|(!\s*#))\s*(/usr(/local)?)?/bin/(env\s+)?(sh|ash|bash|dash|ksh|bats)\b'; then + if head -n1 "${file}" | grep --quiet -E '^\s*((#|!)|(#\s*!)|(!\s*#))\s*(/usr(/local)?)?/bin/(env\s+)?(sh|ash|bash|dash|ksh|bats)\b'; then return 0 fi # ShellCheck shell directive detection - if grep ${RUNNER_DEBUG:+"--quiet"} -E '^\s*#\s*shellcheck\s+shell=(sh|ash|bash|dash|ksh|bats)\s*' "${file}"; then + if grep --quiet -E '^\s*#\s*shellcheck\s+shell=(sh|ash|bash|dash|ksh|bats)\s*' "${file}"; then return 0 fi # Emacs mode detection - if grep ${RUNNER_DEBUG:+"--quiet"} -E '^\s*#\s+-\*-\s+(sh|ash|bash|dash|ksh|bats)\s+-\*-\s*' "${file}"; then + if grep --quiet -E '^\s*#\s+-\*-\s+(sh|ash|bash|dash|ksh|bats)\s+-\*-\s*' "${file}"; then return 0 fi # Vi and Vim modeline filetype detection - if grep ${RUNNER_DEBUG:+"--quiet"} -E '^\s*#\s+vim?:\s+(set\s+)?(ft|filetype)=(sh|ash|bash|dash|ksh|bats)\s*' "${file}"; then + if grep --quiet -E '^\s*#\s+vim?:\s+(set\s+)?(ft|filetype)=(sh|ash|bash|dash|ksh|bats)\s*' "${file}"; then return 0 fi From 9536bc8fec6791209cadbd0c6dd5f6817a5de559 Mon Sep 17 00:00:00 2001 From: Jan Macku Date: Wed, 4 Oct 2023 12:37:15 +0200 Subject: [PATCH 2/2] fix: uninitialized variable RUNNER_DEBUG --- src/functions.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/functions.sh b/src/functions.sh index 5e960285..f113ce20 100644 --- a/src/functions.sh +++ b/src/functions.sh @@ -292,7 +292,7 @@ execute_shellcheck () { # Function to check if the action is run in a Debug mode is_debug () { local result - result=$(is_true "${RUNNER_DEBUG}") + result=$(is_true "${RUNNER_DEBUG:-0}") # shellcheck disable=SC2086 # return require numeric value