File tree Expand file tree Collapse file tree 1 file changed +37
-7
lines changed Expand file tree Collapse file tree 1 file changed +37
-7
lines changed Original file line number Diff line number Diff line change 8
8
export PATH=$PATH :/usr/local/bin
9
9
10
10
exit_status=0
11
+ ENABLE_LIST=" "
11
12
12
- for file in " $@ " ; do
13
- if (head -1 " $file " | grep ' ^#!.*sh' > /dev/null); then
13
+ # Arguments
14
+ parse_arguments () {
15
+ while [ $# -gt 0 ]; do
16
+ # Get param and value using parameter expansion, splitting on = or " "
17
+ param=" ${1% [ =]* } "
18
+ value=" ${1#* [ =]} "
19
+ if [ " $param " = " $value " ]; then value=" $2 " ; fi
20
+ shift
21
+ case " $param " in
22
+ --enable)
23
+ ENABLE_LIST=" $ENABLE_LIST $value "
24
+ ;;
25
+ -* )
26
+ echo " Error: Unknown option: $param " >&2
27
+ exit 1
28
+ ;;
29
+ * )
30
+ PARAMS=" $PARAMS $param "
31
+ ;;
32
+ esac
33
+ done
34
+ ENABLE_LIST=" ${ENABLE_LIST## } " # remove preceeding space
35
+ }
14
36
15
- if ! shellcheck " $file " ; then
16
- exit_status=1
37
+ parse_arguments " $@ "
38
+
39
+ for file in $PARAMS ; do
40
+ if (head -1 " $file " | grep ' ^#!.*sh' > /dev/null); then
41
+ SHELLCHECK_ARGS=" "
42
+ if [ " $ENABLE_LIST " != " " ]; then
43
+ SHELLCHECK_ARGS+=" --enable=\" $ENABLE_LIST \" "
17
44
fi
18
- elif [[ " $file " =~ \. sh$| bash$ ]]; then
19
- echo " $file : missing shebang"
45
+ if ! eval " shellcheck $SHELLCHECK_ARGS \" $file \" " ; then
20
46
exit_status=1
21
- fi
47
+ fi
48
+ elif [[ " $file " =~ \. sh$| bash$ ]]; then
49
+ echo " $file : missing shebang"
50
+ exit_status=1
51
+ fi
22
52
done
23
53
24
54
exit $exit_status
You can’t perform that action at this time.
0 commit comments