Skip to content

Commit fa302a9

Browse files
committed
[CI] Enable shellcheck linting
Adds a linter script to check shell script files for known errors using the shellcheck program. Also checks the shell scripts in the gitian descriptors using the yq program.
1 parent f70c72d commit fa302a9

File tree

19 files changed

+122
-116
lines changed

19 files changed

+122
-116
lines changed

.github/workflows/build-and-test.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on: [push, pull_request]
44
jobs:
55
lint:
66
env:
7-
SHELLCHECK_VERSION: v0.6.0
7+
SHELLCHECK_VERSION: v0.7.1
88
LC_ALL: C
99
runs-on: ubuntu-18.04
1010
defaults:
@@ -27,17 +27,19 @@ jobs:
2727
pip install codespell==1.13.0
2828
pip install flake8==3.8.3
2929
pip install vulture==0.29
30+
pip install yq
3031
3132
curl -sL "https://github.com/koalaman/shellcheck/releases/download/${SHELLCHECK_VERSION}/shellcheck-${SHELLCHECK_VERSION}.linux.x86_64.tar.xz" | tar --xz -xf - --directory /tmp/
32-
export PATH="/tmp/shellcheck-${SHELLCHECK_VERSION}:${PATH}"
33-
echo $PATH
3433
3534
- name: Set TRAVIS_BRANCH workaround env variable
3635
if: github.event_name == 'pull_request'
3736
run: echo "TRAVIS_BRANCH=${{ github.base_ref }}" >> $GITHUB_ENV
3837

3938
- name: Lint
4039
run: |
40+
export PATH="/tmp/shellcheck-${SHELLCHECK_VERSION}:${PATH}"
41+
echo $PATH
42+
4143
git checkout -qf -B master refs/remotes/origin/master
4244
git checkout -qf $GITHUB_SHA
4345
test/lint/git-subtree-check.sh src/secp256k1

autogen.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ export LC_ALL=C
77
set -e
88
srcdir="$(dirname $0)"
99
cd "$srcdir"
10-
if [ -z ${LIBTOOLIZE} ] && GLIBTOOLIZE="`which glibtoolize 2>/dev/null`"; then
10+
if [ -z ${LIBTOOLIZE} ] && GLIBTOOLIZE="$(command -v glibtoolize)"; then
1111
LIBTOOLIZE="${GLIBTOOLIZE}"
1212
export LIBTOOLIZE
1313
fi
14-
which autoreconf >/dev/null || \
14+
command -v autoreconf >/dev/null || \
1515
(echo "configuration failed, please install autoconf first" && exit 1)
1616
autoreconf --install --force --warnings=all

contrib/devtools/gen-manpages.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ BITCOINQT=${BITCOINQT:-$BINDIR/qt/pivx-qt}
1515
[ ! -x $BITCOIND ] && echo "$BITCOIND not found or not executable." && exit 1
1616

1717
# The autodetected version git tag can screw up manpage output a little bit
18-
BTCVER=($($BITCOINCLI --version | head -n1 | awk -F'[ -]' '{ print $6, $7 }'))
18+
read -r -a BTCVER <<< "$($BITCOINCLI --version | head -n1 | awk -F'[ -]' '{ print $6, $7 }')"
1919

2020
# Create a footer file with copyright content.
2121
# This gets autodetected fine for bitcoind if --version-string is not set,

contrib/gitian-descriptors/gitian-linux.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ script: |
5151
export QT_RCC_TEST=1
5252
export QT_RCC_SOURCE_DATE_OVERRIDE=1
5353
export TZ="UTC"
54-
export BUILD_DIR=`pwd`
54+
export BUILD_DIR="$PWD"
5555
mkdir -p ${WRAP_DIR}
5656
if test -n "$GBUILD_CACHE_ENABLED"; then
5757
export SOURCES_PATH=${GBUILD_COMMON_CACHE}
@@ -107,7 +107,7 @@ script: |
107107
rm -f ${WRAP_DIR}/${prog}
108108
cat << EOF > ${WRAP_DIR}/${prog}
109109
#!/usr/bin/env bash
110-
REAL="`which -a ${prog}-8 | grep -v ${WRAP_DIR}/${prog} | head -1`"
110+
REAL="$(which -a ${prog}-8 | grep -v ${WRAP_DIR}/${prog} | head -1)"
111111
for var in "\$@"
112112
do
113113
if [ "\$var" = "-m32" ]; then
@@ -122,7 +122,7 @@ script: |
122122
done
123123
124124
cd pivx
125-
BASEPREFIX=`pwd`/depends
125+
BASEPREFIX="${PWD}/depends"
126126
# Build dependencies for each host
127127
for i in $HOSTS; do
128128
EXTRA_INCLUDES="$EXTRA_INCLUDES_BASE/$i"
@@ -142,10 +142,10 @@ script: |
142142
# Create the release tarball using (arbitrarily) the first host
143143
git update-index --assume-unchanged src/chiabls/contrib/relic/include/relic_conf.h.in
144144
./autogen.sh
145-
CONFIG_SITE=${BASEPREFIX}/`echo "${HOSTS}" | awk '{print $1;}'`/share/config.site ./configure --prefix=/
145+
CONFIG_SITE=${BASEPREFIX}/$(echo "${HOSTS}" | awk '{print $1;}')/share/config.site ./configure --prefix=/
146146
make dist
147-
SOURCEDIST=`echo pivx-*.tar.gz`
148-
DISTNAME=`echo ${SOURCEDIST} | sed 's/.tar.*//'`
147+
SOURCEDIST=$(echo pivx-*.tar.gz)
148+
DISTNAME=${SOURCEDIST/%.tar.gz}
149149
# Correct tar file order
150150
mkdir -p temp
151151
pushd temp
@@ -162,7 +162,7 @@ script: |
162162
export PATH=${BASEPREFIX}/${i}/native/bin:${ORIGPATH}
163163
mkdir -p distsrc-${i}
164164
cd distsrc-${i}
165-
INSTALLPATH=`pwd`/installed/${DISTNAME}
165+
INSTALLPATH="${PWD}/installed/${DISTNAME}"
166166
mkdir -p ${INSTALLPATH}
167167
tar --strip-components=1 -xf ../$SOURCEDIST
168168

contrib/gitian-descriptors/gitian-osx-signer.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ script: |
1717
1818
WRAP_DIR=$HOME/wrapped
1919
mkdir -p ${WRAP_DIR}
20-
export PATH=`pwd`:$PATH
20+
export PATH="$PWD":$PATH
2121
FAKETIME_PROGS="dmg genisoimage"
2222
2323
# Create global faketime wrappers

contrib/gitian-descriptors/gitian-osx.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ script: |
4545
export QT_RCC_TEST=1
4646
export QT_RCC_SOURCE_DATE_OVERRIDE=1
4747
export TZ="UTC"
48-
export BUILD_DIR=`pwd`
48+
export BUILD_DIR="$PWD"
4949
mkdir -p ${WRAP_DIR}
5050
if test -n "$GBUILD_CACHE_ENABLED"; then
5151
export SOURCES_PATH=${GBUILD_COMMON_CACHE}
@@ -86,7 +86,7 @@ script: |
8686
export PATH=${WRAP_DIR}:${PATH}
8787
8888
cd pivx
89-
BASEPREFIX=`pwd`/depends
89+
BASEPREFIX="${PWD}/depends"
9090
9191
mkdir -p ${BASEPREFIX}/SDKs
9292
tar -C ${BASEPREFIX}/SDKs -xf ${BUILD_DIR}/Xcode-11.3.1-11C505-extracted-SDK-with-libcxx-headers.tar.gz
@@ -105,10 +105,10 @@ script: |
105105
# Create the release tarball using (arbitrarily) the first host
106106
git update-index --assume-unchanged src/chiabls/contrib/relic/include/relic_conf.h.in
107107
./autogen.sh
108-
CONFIG_SITE=${BASEPREFIX}/`echo "${HOSTS}" | awk '{print $1;}'`/share/config.site ./configure --prefix=/
108+
CONFIG_SITE=${BASEPREFIX}/$(echo "${HOSTS}" | awk '{print $1;}')/share/config.site ./configure --prefix=/
109109
make dist
110-
SOURCEDIST=`echo pivx-*.tar.gz`
111-
DISTNAME=`echo ${SOURCEDIST} | sed 's/.tar.*//'`
110+
SOURCEDIST=$(echo pivx-*.tar.gz)
111+
DISTNAME=${SOURCEDIST/%.tar.gz}
112112
113113
# Correct tar file order
114114
mkdir -p temp
@@ -126,7 +126,7 @@ script: |
126126
export PATH=${BASEPREFIX}/${i}/native/bin:${ORIGPATH}
127127
mkdir -p distsrc-${i}
128128
cd distsrc-${i}
129-
INSTALLPATH=`pwd`/installed/${DISTNAME}
129+
INSTALLPATH="${PWD}/installed/${DISTNAME}"
130130
mkdir -p ${INSTALLPATH}
131131
tar --strip-components=1 -xf ../$SOURCEDIST
132132

contrib/gitian-descriptors/gitian-win-signer.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ files:
1919
script: |
2020
set -e -o pipefail
2121
22-
BUILD_DIR=`pwd`
22+
BUILD_DIR="$PWD"
2323
SIGDIR=${BUILD_DIR}/signature/win
2424
UNSIGNED_DIR=${BUILD_DIR}/unsigned
2525
@@ -35,7 +35,7 @@ script: |
3535
./configure --without-gsf --without-curl --disable-dependency-tracking
3636
make
3737
find ${UNSIGNED_DIR} -name "*-unsigned.exe" | while read i; do
38-
INFILE="`basename "${i}"`"
39-
OUTFILE="`echo "${INFILE}" | sed s/-unsigned//`"
38+
INFILE="$(basename "${i}")"
39+
OUTFILE="${INFILE/%-unsigned}"
4040
./osslsigncode attach-signature -in "${i}" -out "${OUTDIR}/${OUTFILE}" -sigin "${SIGDIR}/${INFILE}.pem"
4141
done

contrib/gitian-descriptors/gitian-win.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ script: |
4040
export QT_RCC_TEST=1
4141
export QT_RCC_SOURCE_DATE_OVERRIDE=1
4242
export TZ="UTC"
43-
export BUILD_DIR=`pwd`
43+
export BUILD_DIR="$PWD"
4444
mkdir -p ${WRAP_DIR}
4545
if test -n "$GBUILD_CACHE_ENABLED"; then
4646
export SOURCES_PATH=${GBUILD_COMMON_CACHE}
@@ -96,7 +96,7 @@ script: |
9696
export PATH=${WRAP_DIR}:${PATH}
9797
9898
cd pivx
99-
BASEPREFIX=`pwd`/depends
99+
BASEPREFIX="${PWD}/depends"
100100
# Build dependencies for each host
101101
for i in $HOSTS; do
102102
make ${MAKEOPTS} -C ${BASEPREFIX} HOST="${i}"
@@ -112,10 +112,10 @@ script: |
112112
# Create the release tarball using (arbitrarily) the first host
113113
git update-index --assume-unchanged src/chiabls/contrib/relic/include/relic_conf.h.in
114114
./autogen.sh
115-
CONFIG_SITE=${BASEPREFIX}/`echo "${HOSTS}" | awk '{print $1;}'`/share/config.site ./configure --prefix=/
115+
CONFIG_SITE=${BASEPREFIX}//$(echo "${HOSTS}" | awk '{print $1;}')/share/config.site ./configure --prefix=/
116116
make dist
117-
SOURCEDIST=`echo pivx-*.tar.gz`
118-
DISTNAME=`echo ${SOURCEDIST} | sed 's/.tar.*//'`
117+
SOURCEDIST=$(echo pivx-*.tar.gz)
118+
DISTNAME=${SOURCEDIST/%.tar.gz}
119119
# Correct tar file order
120120
mkdir -p temp
121121
pushd temp
@@ -132,7 +132,7 @@ script: |
132132
export PATH=${BASEPREFIX}/${i}/native/bin:${ORIGPATH}
133133
mkdir -p distsrc-${i}
134134
cd distsrc-${i}
135-
INSTALLPATH=`pwd`/installed/${DISTNAME}
135+
INSTALLPATH="${PWD}/installed/${DISTNAME}"
136136
mkdir -p ${INSTALLPATH}
137137
tar --strip-components=1 -xf ../$SOURCEDIST
138138

contrib/install_db4.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ if [ -z "${1}" ]; then
1414
fi
1515

1616
expand_path() {
17-
echo "$(cd "${1}" && pwd -P)"
17+
cd "${1}" && pwd -P
1818
}
1919

2020
BDB_PREFIX="$(expand_path ${1})/db4"; shift;
@@ -23,7 +23,7 @@ BDB_HASH='12edc0df75bf9abd7f82f821795bcee50f42cb2e5f76a6a281b85732798364ef'
2323
BDB_URL="https://download.oracle.com/berkeley-db/${BDB_VERSION}.tar.gz"
2424

2525
check_exists() {
26-
which "$1" >/dev/null 2>&1
26+
command -v "$1" >/dev/null 2>&1
2727
}
2828

2929
sha256_check() {
@@ -95,7 +95,9 @@ make install
9595
echo
9696
echo "db4 build complete."
9797
echo
98+
# shellcheck disable=SC2016
9899
echo 'When compiling pivxd, run `./configure` in the following way:'
99100
echo
100101
echo " export BDB_PREFIX='${BDB_PREFIX}'"
102+
# shellcheck disable=SC2016
101103
echo ' ./configure BDB_LIBS="-L${BDB_PREFIX}/lib -ldb_cxx-4.8" BDB_CFLAGS="-I${BDB_PREFIX}/include" ...'

contrib/macdeploy/detached-sig-apply.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@ if [ -z "${CODESIGN_ALLOCATE}" ]; then
3636
fi
3737

3838
find ${TEMPDIR} -name "*.sign" | while read i; do
39-
SIZE=`stat -c %s "${i}"`
40-
TARGET_FILE="`echo "${i}" | sed 's/\.sign$//'`"
39+
SIZE=$(stat -c %s "${i}")
40+
TARGET_FILE="$(echo "${i}" | sed 's/\.sign$//')"
4141

4242
echo "Allocating space for the signature of size ${SIZE} in ${TARGET_FILE}"
4343
${CODESIGN_ALLOCATE} -i "${TARGET_FILE}" -a ${ARCH} ${SIZE} -o "${i}.tmp"
4444

45-
OFFSET=`${PAGESTUFF} "${i}.tmp" -p | tail -2 | grep offset | sed 's/[^0-9]*//g'`
45+
OFFSET=$(${PAGESTUFF} "${i}.tmp" -p | tail -2 | grep offset | sed 's/[^0-9]*//g')
4646
if [ -z ${QUIET} ]; then
4747
echo "Attaching signature at offset ${OFFSET}"
4848
fi

0 commit comments

Comments
 (0)