Skip to content

Commit

Permalink
scripts: fix shellws check
Browse files Browse the repository at this point in the history
Originally this was intended to be a clean up. But after further
investigation the original code didn't work. It didn't detect tabs in
shell scripts.

Signed-off-by: Ivan Valdes <[email protected]>
  • Loading branch information
ivanvc committed Dec 12, 2024
1 parent 0f9f447 commit d4e2679
Showing 1 changed file with 5 additions and 15 deletions.
20 changes: 5 additions & 15 deletions scripts/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -340,24 +340,14 @@ function shellcheck_pass {
}

function shellws_pass {
TAB=$'\t'
log_callout "Ensuring no tab-based indention in shell scripts"
local files
files=$(find ./ -name '*.sh' -print0 | xargs -0 )
# shellcheck disable=SC2206
files=( ${files[@]} "./scripts/build-binary.sh" "./scripts/build-docker.sh" "./scripts/release.sh" )
log_cmd "grep -E -n $'^ *${TAB}' ${files[*]}"
# shellcheck disable=SC2086
if grep -E -n $'^ *${TAB}' "${files[@]}" | sed $'s|${TAB}|[\\\\tab]|g'; then
local files
if ! files=$(find . -name '*.sh' -print0 | xargs -0 awk '/^\s*\t/{print FILENAME;exit 1}'); then
log_error "FAIL: found tab-based indention in bash scripts. Use ' ' (double space)."
local files_with_tabs
files_with_tabs=$(grep -E -l $'^ *\\t' "${files[@]}")
log_warning "Try: sed -i 's|\\t| |g' $files_with_tabs"
return 1
else
log_success "SUCCESS: no tabulators found."
return 0
log_warning "Try: sed -i 's|\\t| |g' ${files}"
return 255
fi
log_success "SUCCESS: no tabulators found."
}

function markdown_marker_pass {
Expand Down

0 comments on commit d4e2679

Please sign in to comment.