Skip to content

Commit 2671585

Browse files
committed
Read options with mapfile rather than loop
1 parent 3f64a21 commit 2671585

1 file changed

Lines changed: 3 additions & 6 deletions

File tree

hooks/command

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ function plugin_read_list() {
2121

2222
IFS=$'\n\t'
2323
files=()
24-
options=()
2524

2625
# Evaluate all the globs and return the files that exist
2726
for file in $(plugin_read_list FILES) ; do
@@ -30,16 +29,14 @@ for file in $(plugin_read_list FILES) ; do
3029
fi
3130
done
3231

33-
# Read in the options to pass to shellcheck
34-
for option in $(plugin_read_list OPTIONS) ; do
35-
options+=("$option")
36-
done
37-
3832
if [[ -z ${files:-} ]] ; then
3933
echo "No files found to shellcheck"
4034
exit 1
4135
fi
4236

37+
# Read in the options to pass to shellcheck
38+
mapfile -t options<<<"$(plugin_read_list OPTIONS)"
39+
4340
echo "+++ Running shellcheck on ${#files[@]} files"
4441
if docker run --rm -v "$PWD:/mnt" --workdir "/mnt" koalaman/shellcheck "${options[@]+${options[@]}}" "${files[@]}" ; then
4542
echo "Files are ok ✅"

0 commit comments

Comments
 (0)