mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-08-29 04:57:52 +00:00
[#1574] add tools/shellcheck-all.sh
This commit is contained in:
parent
9eff52161c
commit
b8353ec752
59
tools/shellcheck-all.sh
Executable file
59
tools/shellcheck-all.sh
Executable file
@ -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)
|
Loading…
x
Reference in New Issue
Block a user