2018-06-20 11:54:54 +02:00
|
|
|
#!/usr/bin/env bash
|
2018-04-03 15:30:55 +02:00
|
|
|
#
|
|
|
|
# Copyright (c) 2018 The Bitcoin Core developers
|
|
|
|
# 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 14:32:51 +02:00
|
|
|
export LC_ALL=C
|
|
|
|
|
|
|
|
# The shellcheck binary segfault/coredumps in Travis with LC_ALL=C
|
|
|
|
# It does not do so in Ubuntu 14.04, 16.04, 18.04 in versions 0.3.3, 0.3.7, 0.4.6
|
|
|
|
# respectively. So export LC_ALL=C is set as required by lint-shell-locale.sh
|
|
|
|
# but unset here in case of running in Travis.
|
|
|
|
if [ "$TRAVIS" = "true" ]; then
|
2019-01-16 14:50:50 +01:00
|
|
|
unset LC_ALL
|
2018-08-02 14:32:51 +02:00
|
|
|
fi
|
2018-06-13 16:50:48 +02:00
|
|
|
|
2018-08-31 00:57:42 +02:00
|
|
|
if ! command -v shellcheck > /dev/null; then
|
|
|
|
echo "Skipping shell linting since shellcheck is not installed."
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2018-04-03 15:30:55 +02:00
|
|
|
# Disabled warnings:
|
2019-01-15 03:55:20 +01:00
|
|
|
disabled=(
|
|
|
|
SC1087 # Use braces when expanding arrays, e.g. ${array[idx]} (or ${var}[.. to quiet).
|
|
|
|
SC2001 # See if you can use ${variable//search/replace} instead.
|
|
|
|
SC2004 # $/${} is unnecessary on arithmetic variables.
|
|
|
|
SC2005 # Useless echo? Instead of 'echo $(cmd)', just use 'cmd'.
|
|
|
|
SC2006 # Use $(..) instead of legacy `..`.
|
|
|
|
SC2016 # Expressions don't expand in single quotes, use double quotes for that.
|
|
|
|
SC2028 # echo won't expand escape sequences. Consider printf.
|
|
|
|
SC2046 # Quote this to prevent word splitting.
|
|
|
|
SC2048 # Use "$@" (with quotes) to prevent whitespace problems.
|
|
|
|
SC2066 # Since you double quoted this, it will not word split, and the loop will only run once.
|
|
|
|
SC2086 # Double quote to prevent globbing and word splitting.
|
|
|
|
SC2116 # Useless echo? Instead of 'cmd $(echo foo)', just use 'cmd foo'.
|
|
|
|
SC2162 # read without -r will mangle backslashes.
|
2019-01-16 14:50:50 +01:00
|
|
|
SC2166 # Prefer [ p ] {&&,||} [ q ] as [ p -{a,o} q ] is not well defined.
|
2019-01-15 03:55:20 +01:00
|
|
|
SC2181 # Check exit code directly with e.g. 'if mycmd;', not indirectly with $?.
|
|
|
|
SC2206 # Quote to prevent word splitting, or split robustly with mapfile or read -a.
|
|
|
|
SC2207 # Prefer mapfile or read -a to split command output (or quote to avoid splitting).
|
|
|
|
SC2230 # which is non-standard. Use builtin 'command -v' instead.
|
|
|
|
SC2236 # Don't force -n instead of ! -z.
|
|
|
|
)
|
|
|
|
shellcheck -e "$(IFS=","; echo "${disabled[*]}")" \
|
2018-04-03 15:30:55 +02:00
|
|
|
$(git ls-files -- "*.sh" | grep -vE 'src/(secp256k1|univalue)/')
|