-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathtest.sh
More file actions
executable file
·42 lines (37 loc) · 922 Bytes
/
test.sh
File metadata and controls
executable file
·42 lines (37 loc) · 922 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
34
35
36
37
38
39
40
41
42
#!/usr/bin/env bash
# set -Exeuo pipefail
# Exit on error
set -e
# Exit on error in any of pipe commands
set -o pipefail
ERRORS=()
ERRFMT=()
# Run shfmt on all the script
for f in $(find . -type f -name "*.sh" -not -name "setup.sh" | sort -u); do
if file "$f" | grep -q shell; then
{
# add to errors
[[ $(shfmt -i 2 -ci -l "$f") ]] && ERRFMT+=("$f")
} || {
echo "[OK]: sucessfully formatted $f"
}
fi
done
# Run shellcheck on all the script
for f in $(find . -type f -name "*.sh" -not -name "setup.sh" | sort -u); do
if file "$f" | grep -q shell; then
{
shellcheck "$f" && echo "[OK]: sucessfully linted $f"
} || {
# add to errors
ERRORS+=("$f")
}
fi
done
if [ ${#ERRORS[@]} -eq 0 ]; then
echo "You are a Bash Wizard, No errors!"
else
echo "These files failed shellcheck: ${ERRORS[*]}"
echo "These files failed shfmt: ${ERRFMT[*]}"
exit 1
fi