-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshellcheck-scripts
More file actions
executable file
·33 lines (26 loc) · 945 Bytes
/
shellcheck-scripts
File metadata and controls
executable file
·33 lines (26 loc) · 945 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env bash
# @description Run shellcheck over shell scripts in the repo. When invoked with no paths, lints every in-scope script.
# @arg $@ paths Optional file or directory paths to lint; omit to lint the full in-scope set.
# @exitcode 0 All files pass shellcheck.
# @exitcode 1 One or more files failed shellcheck.
set -Eeuo pipefail
IFS=$'\n\t'
#shellcheck disable=SC1091
source "${SCRIPTS_DIR}/.functions.bash"
log::enable_err_trap
args::handle_help_flag "$@"
system::require_bash_version 4 3
shell_scripts::assert_paths_exist "$@"
files::create_temp candidates_tmp
# shellcheck disable=SC2154 # candidates_tmp set via nameref inside files::create_temp
shell_scripts::find "$@" > "${candidates_tmp}"
mapfile -t candidates < "${candidates_tmp}"
if [[ "${#candidates[@]}" -eq 0 ]]; then
exit 0
fi
files=()
shell_scripts::filter files "${candidates[@]}"
if [[ "${#files[@]}" -eq 0 ]]; then
exit 0
fi
shellcheck "${files[@]}"