Skip to content

Commit

Permalink
Fix shfmt
Browse files Browse the repository at this point in the history
  • Loading branch information
elijahr committed Apr 9, 2024
1 parent e8268d3 commit d6600d5
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 6 deletions.
23 changes: 23 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,26 @@ charset = utf-8
end_of_line = lf
trim_trailing_whitespace = true
insert_final_newline = true
binary_next_line = true
switch_case_indent = true
space_redirects = true
keep_padding = false
function_next_line = true
never_split = true

[*.sh]
shell_variant = posix

[*.py]
indent_size = 4

[tools/.bundle]
ignore = true
[tools/asdf]
ignore = true
[tools/bin]
ignore = true
[tools/node_modules]
ignore = true
[tools/uncrustify-*]
ignore = true
16 changes: 11 additions & 5 deletions lib/tools.bash
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ run_tool() {
fi

status=0
IFS= read -r original < <(cat "${path}")
original=$(cat "${path}")
IFS= read -r stdout < <(mktemp)
IFS= read -r stderr < <(mktemp)

Expand Down Expand Up @@ -147,7 +147,7 @@ run_tool_nimpretty() {
if [[ "$(cat "${tmp}")" == "$(cat "${path}")" ]]; then
printf " ↳ %s%s%s\n" "${tool}" "${DOTS:offset}" "ok"
else
IFS= read -r patch < <(diff -u "${path}" "${tmp}")
patch=$(diff -u "${path}" "${tmp}")
if [[ -n ${patch} ]]; then
if [[ ${mode} == "write" ]]; then
cat "${tmp}" >"${path}"
Expand Down Expand Up @@ -314,7 +314,7 @@ run_tool_shfmt() {
return 0
fi
status=0
IFS= read -r original < <(cat "${path}")
original=$(cat "${path}")
IFS= read -r stdout < <(mktemp)
IFS= read -r stderr < <(mktemp)

Expand Down Expand Up @@ -347,6 +347,12 @@ run_tool_shfmt() {
printf " ↳ %s%s%s\n" "${tool}" "${DOTS:offset}" "ok"
fi
else
echo ">>> $path"
cat "${path}"
echo "<<< $path"
echo ">>> original"
echo "${original}"
echo "<<< original"
status=0
printf " ↳ %s%s%s\n" "${tool}" "${DOTS:offset}" "wrote"
fi
Expand Down Expand Up @@ -476,7 +482,7 @@ run_tool_uncrustify() {
IFS= read -r stderr < <(mktemp)
status=0

readarray -t cmd < <(interpolate \
cmd=$(interpolate \
"tool" "uncrustify" \
"lintball_dir" "${LINTBALL_DIR}" \
"lang" "${lang}" \
Expand All @@ -490,7 +496,7 @@ run_tool_uncrustify() {
if [[ "$(cat "${stdout}")" == "$(cat "${path}")" ]]; then
printf " ↳ %s%s%s\n" "${tool}" "${DOTS:offset}" "ok"
else
IFS= read -r patch < <(diff -u "${path}" "${stdout}")
patch=$(diff -u "${path}" "${stdout}")
if [[ -n ${patch} ]]; then
if [[ ${mode} == "write" ]]; then
cat "${stdout}" >"${path}"
Expand Down
2 changes: 1 addition & 1 deletion test/install-githooks.bats
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@ teardown() {

@test 'lintball install-githooks does not cause shellcheck errors' {
run lintball install-githooks --no # 3>&-
run lintball check .githooks # 3>&-
run lintball check .githooks # 3>&-
assert_success
}

0 comments on commit d6600d5

Please sign in to comment.