1
1
#! /usr/bin/env bash
2
2
#
3
- # Copyright (c) 2018 The Bitcoin Core developers
3
+ # Copyright (c) 2018-2019 The Bitcoin Core developers
4
4
# Distributed under the MIT software license, see the accompanying
5
5
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
6
6
#
@@ -16,16 +16,48 @@ if [ "$TRAVIS" = "true" ]; then
16
16
unset LC_ALL
17
17
fi
18
18
19
- if ! command -v shellcheck > /dev/null; then
20
- echo " Skipping shell linting since shellcheck is not installed."
21
- exit 0
22
- fi
23
-
24
19
# Disabled warnings:
25
20
disabled=(
26
21
SC2046 # Quote this to prevent word splitting.
27
22
SC2086 # Double quote to prevent globbing and word splitting.
28
23
SC2162 # read without -r will mangle backslashes.
29
24
)
30
- shellcheck -e " $( IFS=" ," ; echo " ${disabled[*]} " ) " \
31
- $( git ls-files -- " *.sh" | grep -vE ' src/(secp256k1|univalue)/' )
25
+ disabled_gitian=(
26
+ SC2001 # See if you can use ${variable//search/replace} instead.
27
+ SC2006 # Use $(...) notation instead of legacy backticked `...`.
28
+ SC2094 # Make sure not to read and write the same file in the same pipeline.
29
+ SC2129 # Consider using { cmd1; cmd2; } >> file instead of individual redirects.
30
+ SC2155 # Declare and assign separately to avoid masking return values.
31
+ SC2230 # which is non-standard. Use builtin 'command -v' instead.
32
+ )
33
+
34
+ EXIT_CODE=0
35
+
36
+ if ! command -v shellcheck > /dev/null; then
37
+ echo " Skipping shell linting since shellcheck is not installed."
38
+ exit $EXIT_CODE
39
+ fi
40
+
41
+ EXCLUDE=" --exclude=$( IFS=' ,' ; echo " ${disabled[*]} " ) "
42
+ if ! shellcheck " $EXCLUDE " $( git ls-files -- ' *.sh' | grep -vE ' src/(leveldb|secp256k1|univalue)/' ) ; then
43
+ EXIT_CODE=1
44
+ fi
45
+
46
+ if ! command -v yq > /dev/null; then
47
+ echo " Skipping Gitian desriptor scripts checking since yq is not installed."
48
+ exit $EXIT_CODE
49
+ fi
50
+
51
+ EXCLUDE_GITIAN=${EXCLUDE} " ,$( IFS=' ,' ; echo " ${disabled_gitian[*]} " ) "
52
+ for descriptor in $( git ls-files -- ' contrib/gitian-descriptors/*.yml' )
53
+ do
54
+ echo
55
+ echo " $descriptor "
56
+ # Use #!/bin/bash as gitian-builder/bin/gbuild does to complete a script.
57
+ SCRIPT=$' #!/bin/bash\n ' $( yq -r .script " $descriptor " )
58
+ if ! echo " $SCRIPT " | shellcheck " $EXCLUDE_GITIAN " -; then
59
+ EXIT_CODE=1
60
+ fi
61
+ done
62
+
63
+ exit $EXIT_CODE
0 commit comments