aboutsummaryrefslogtreecommitdiff
path: root/test/lint/lint-shell.sh
diff options
context:
space:
mode:
Diffstat (limited to 'test/lint/lint-shell.sh')
-rwxr-xr-xtest/lint/lint-shell.sh24
1 files changed, 22 insertions, 2 deletions
diff --git a/test/lint/lint-shell.sh b/test/lint/lint-shell.sh
index 5f5fa9a925..9af3c10ed6 100755
--- a/test/lint/lint-shell.sh
+++ b/test/lint/lint-shell.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
#
# Copyright (c) 2018 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
@@ -6,7 +6,24 @@
#
# Check for shellcheck warnings in shell scripts.
+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
+ unset LC_ALL
+fi
+
+if ! command -v shellcheck > /dev/null; then
+ echo "Skipping shell linting since shellcheck is not installed."
+ exit 0
+fi
+
# Disabled warnings:
+# SC1087: Use braces when expanding arrays, e.g. ${array[idx]} (or ${var}[.. to quiet).
+# SC1117: Backslash is literal in "\.". Prefer explicit escaping: "\\.".
# 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'.
@@ -23,5 +40,8 @@
# SC2166: Prefer [ p ] && [ q ] as [ p -a q ] is not well defined.
# SC2166: Prefer [ p ] || [ q ] as [ p -o q ] is not well defined.
# SC2181: Check exit code directly with e.g. 'if mycmd;', not indirectly with $?.
-shellcheck -e SC2001,SC2004,SC2005,SC2006,SC2016,SC2028,SC2046,SC2048,SC2066,SC2086,SC2116,SC2148,SC2162,SC2166,SC2181 \
+# 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.
+shellcheck -e SC1087,SC1117,SC2001,SC2004,SC2005,SC2006,SC2016,SC2028,SC2046,SC2048,SC2066,SC2086,SC2116,SC2148,SC2162,SC2166,SC2181,SC2206,SC2207,SC2230 \
$(git ls-files -- "*.sh" | grep -vE 'src/(secp256k1|univalue)/')