2018-06-20 05:54:54 -04:00
|
|
|
#!/usr/bin/env bash
|
2018-04-03 10:30:55 -03:00
|
|
|
#
|
2020-04-16 13:14:08 -04:00
|
|
|
# Copyright (c) 2018-2020 The Bitcoin Core developers
|
2018-04-03 10:30:55 -03:00
|
|
|
# Distributed under the MIT software license, see the accompanying
|
|
|
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
#
|
|
|
|
# Check for shellcheck warnings in shell scripts.
|
|
|
|
|
2018-08-02 08:32:51 -04:00
|
|
|
export LC_ALL=C
|
|
|
|
|
2018-04-03 10:30:55 -03:00
|
|
|
# Disabled warnings:
|
2019-01-14 23:55:20 -03:00
|
|
|
disabled=(
|
|
|
|
SC2046 # Quote this to prevent word splitting.
|
|
|
|
SC2086 # Double quote to prevent globbing and word splitting.
|
|
|
|
SC2162 # read without -r will mangle backslashes.
|
|
|
|
)
|
2019-11-03 15:55:06 -03:00
|
|
|
|
|
|
|
EXIT_CODE=0
|
|
|
|
|
|
|
|
if ! command -v shellcheck > /dev/null; then
|
|
|
|
echo "Skipping shell linting since shellcheck is not installed."
|
|
|
|
exit $EXIT_CODE
|
|
|
|
fi
|
|
|
|
|
2020-04-28 12:51:15 -04:00
|
|
|
SHELLCHECK_CMD=(shellcheck --external-sources --check-sourced)
|
2019-11-03 15:55:06 -03:00
|
|
|
EXCLUDE="--exclude=$(IFS=','; echo "${disabled[*]}")"
|
2020-11-09 17:00:48 -03:00
|
|
|
SOURCED_FILES=$(git ls-files | xargs gawk '/^# shellcheck shell=/ {print FILENAME} {nextfile}') # Check shellcheck directive used for sourced files
|
|
|
|
if ! "${SHELLCHECK_CMD[@]}" "$EXCLUDE" $SOURCED_FILES $(git ls-files -- '*.sh' | grep -vE 'src/(leveldb|secp256k1|univalue)/'); then
|
2019-11-03 15:55:06 -03:00
|
|
|
EXIT_CODE=1
|
|
|
|
fi
|
|
|
|
|
|
|
|
exit $EXIT_CODE
|