custom-checks: handle multiple dirs
This also fixes a [shellcheck issue](https://github.com/koalaman/shellcheck/wiki/SC2013).
This commit is contained in:
parent
10679b29c3
commit
236da06050
@ -44,24 +44,26 @@ fi
|
|||||||
|
|
||||||
shopt -s globstar
|
shopt -s globstar
|
||||||
|
|
||||||
directory="$1"
|
directories=("$@")
|
||||||
|
|
||||||
check_errors() {
|
check_errors() {
|
||||||
regex="$1"
|
regex="$1"
|
||||||
message="$2"
|
message="$2"
|
||||||
|
|
||||||
for match in $(
|
for directory in "${directories[@]}"; do
|
||||||
grep -n "$regex" "$directory"/**/*.vim \
|
while IFS= read -r match; do
|
||||||
| grep -o '^[^:]\+:[0-9]\+' \
|
|
||||||
| sed 's:^\./::'
|
|
||||||
); do
|
|
||||||
RETURN_CODE=1
|
RETURN_CODE=1
|
||||||
echo "$match $message"
|
echo "$match $message"
|
||||||
|
done < <(grep -n "$regex" "$directory"/**/*.vim \
|
||||||
|
| grep -o '^[^:]\+:[0-9]\+' \
|
||||||
|
| sed 's:^\./::')
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
if (( FIX_ERRORS )); then
|
if (( FIX_ERRORS )); then
|
||||||
|
for directory in "${directories[@]}"; do
|
||||||
sed -i "s/^\(function.*)\) *$/\1 abort/" "$directory"/**/*.vim
|
sed -i "s/^\(function.*)\) *$/\1 abort/" "$directory"/**/*.vim
|
||||||
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
check_errors \
|
check_errors \
|
||||||
|
Loading…
Reference in New Issue
Block a user