diff options
author | Andrei Pavel <andrei@isc.org> | 2020-12-03 10:17:12 +0100 |
---|---|---|
committer | Andrei Pavel <andrei@isc.org> | 2020-12-14 11:08:11 +0100 |
commit | b8353ec752fc94890a2ed584b35a1fb93bbe2b9a (patch) | |
tree | e06be897efdab60091529d6be5b5ae9aae8cf21d | |
parent | [#1605] fixed bump lib versions script (diff) | |
download | kea-b8353ec752fc94890a2ed584b35a1fb93bbe2b9a.tar.xz kea-b8353ec752fc94890a2ed584b35a1fb93bbe2b9a.zip |
[#1574] add tools/shellcheck-all.sh
-rwxr-xr-x | tools/shellcheck-all.sh | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/tools/shellcheck-all.sh b/tools/shellcheck-all.sh new file mode 100755 index 0000000000..b6d9601ff6 --- /dev/null +++ b/tools/shellcheck-all.sh @@ -0,0 +1,59 @@ +#!/bin/sh + +# Copyright (C) 2020 Internet Systems Consortium, Inc. ("ISC") +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +# Usage: +# +# ./tools/shellcheck-all.sh [-d|--debug] [-h|--help] +# +# Run to shellcheck all shell scripts inside this repository. + +# Exit with error if commands exit with non-zero and if undefined variables are +# used. +set -eu + +# Print usage. +print_usage() { + printf \ +'Usage: %s {{options}} +Options: + [-d|--debug] enable debug mode, showing every executed command + [-h|--help] print usage (this text) +' \ + "$(basename "${0}")" +} + +# Define some ANSI color codes. +if test -t 1; then + red='\033[91m' + reset='\033[0m' +else + red= + reset= +fi + +# Parse parameters. +while test ${#} -gt 0; do + case "${1}" in + # [-d|--debug] enable debug mode, showing every executed command + '-d'|'--debug') set -vx ;; + + # [-h|--help] print usage (this text). + '-h'|'--help') print_usage ;; + + # Unrecognized argument + *) + printf "${red}ERROR: Unrecognized argument '%s'${reset}\\n" "${1}" 1>&2; print_usage; exit 1 ;; + esac; shift +done + +# Change directory to Kea' top level build directory. +root_path=$(cd "$(dirname "${0}")/.." && pwd) +cd "${root_path}" + +# shellcheck disable=SC2046 +shellcheck $(grep -F 'SCRIPTS+=' ./.gitlab-ci.yml | cut -d '"' -f 2 | xargs | sort -uV) |