Commit 44135cf3 authored by Vojtěch Horký's avatar Vojtěch Horký
Browse files

Add assert_is_shellchecked_2

parent ca3a9ec9
......@@ -103,3 +103,34 @@ assert_is_shellchecked() {
| fail
fi
}
assert_is_shellchecked_2() {
local severity="${1:-info}"
local script="${script:-}"
if [[ -z "${script}" ]]; then
script="${NSWI177_MAIN_SCRIPT:?}"
fi
local script_basename="$( basename "${script}" )"
mkdir -p "${NSWI177_TEMP_BASE:?}/shellcheck"
sed '/#.*shellcheck.*disable/{s:all::g;s:\([Ss][cC][0-9,-]*\)::g}' "${script}" >"${NSWI177_TEMP_BASE:?}/shellcheck/${script_basename}"
if [ -n "${extra_files:-}" ]; then
local extra_file
local extra_files_arr
read -r -a extra_files_arr <<<"$extra_files"
for extra_file in "${extra_files_arr[@]}"; do
touch "${extra_file}"
done
fi
launch shellcheck -x -S "$severity" "${NSWI177_TEMP_BASE:?}/shellcheck/${script_basename}" --format gcc
if [ "$status" -ne 0 ]; then
echo "$output" \
| sed \
-e 's#/dev/shm/nswi177-bats-[A-Za-z0-9]*/shellcheck/##g' \
-e 's#/tmp/nswi177-bats-[A-Za-z0-9]*/shellcheck/##g' \
| batslib_decorate "Shellcheck found following issues (severity $severity)" \
| fail
fi
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment