Format shell scripts with shfmt.

All changes in this patch were performed automatically with `shfmt` with
configuration flags specified in `.pre-commit-config.yaml`.

In addition to fixing whitespace the roundtrip through shfmt's AST also
transforms command substitutions

    `cmd`
    # becomes
    $(cmd)

and some redirects

    >&2 echo "msg"
    # becomes
    echo >&2 "msg"
This commit is contained in:
Benjamin Bannier 2021-11-24 22:48:46 +01:00
parent e0b4659488
commit 1f388e3f40
34 changed files with 369 additions and 379 deletions

144
configure vendored
View file

@ -118,7 +118,7 @@ Usage: $0 [OPTION]... [VAR=VALUE]...
CXXFLAGS C++ compiler flags
"
sourcedir="$( cd "$( dirname "$0" )" && pwd )"
sourcedir="$(cd "$(dirname "$0")" && pwd)"
if [ ! -e "$sourcedir/cmake/COPYING" ] && [ -d "$sourcedir/.git" ]; then
echo "\
@ -128,8 +128,8 @@ This typically means that you performed a non-recursive git clone of
Zeek. To check out the required subdirectories, please execute:
( cd $sourcedir && git submodule update --recursive --init )
" >&2;
exit 1;
" >&2
exit 1
fi
# Function to append a CMake cache entry definition to the
@ -137,14 +137,14 @@ fi
# $1 is the cache entry variable name
# $2 is the cache entry variable type
# $3 is the cache entry variable value
append_cache_entry () {
append_cache_entry() {
CMakeCacheEntries="$CMakeCacheEntries -D $1:$2=$3"
}
# Function to remove a CMake cache entry definition from the
# CMakeCacheEntries variable
# $1 is the cache entry variable name
remove_cache_entry () {
remove_cache_entry() {
CMakeCacheEntries="$CMakeCacheEntries -U $1"
# Even with -U, cmake still warns by default if
@ -156,22 +156,22 @@ remove_cache_entry () {
builddir=build
prefix=/usr/local/zeek
CMakeCacheEntries=""
append_cache_entry CMAKE_INSTALL_PREFIX PATH $prefix
append_cache_entry ZEEK_ROOT_DIR PATH $prefix
append_cache_entry CMAKE_INSTALL_PREFIX PATH $prefix
append_cache_entry ZEEK_ROOT_DIR PATH $prefix
append_cache_entry ZEEK_SCRIPT_INSTALL_PATH STRING $prefix/share/zeek
append_cache_entry ZEEK_ETC_INSTALL_DIR PATH $prefix/etc
append_cache_entry ENABLE_DEBUG BOOL false
append_cache_entry ENABLE_PERFTOOLS BOOL false
append_cache_entry ENABLE_JEMALLOC BOOL false
append_cache_entry BUILD_SHARED_LIBS BOOL true
append_cache_entry INSTALL_AUX_TOOLS BOOL true
append_cache_entry INSTALL_BTEST BOOL true
append_cache_entry INSTALL_BTEST_PCAPS BOOL true
append_cache_entry INSTALL_ZEEK_ARCHIVER BOOL true
append_cache_entry INSTALL_ZEEKCTL BOOL true
append_cache_entry INSTALL_ZKG BOOL true
append_cache_entry ZEEK_ETC_INSTALL_DIR PATH $prefix/etc
append_cache_entry ENABLE_DEBUG BOOL false
append_cache_entry ENABLE_PERFTOOLS BOOL false
append_cache_entry ENABLE_JEMALLOC BOOL false
append_cache_entry BUILD_SHARED_LIBS BOOL true
append_cache_entry INSTALL_AUX_TOOLS BOOL true
append_cache_entry INSTALL_BTEST BOOL true
append_cache_entry INSTALL_BTEST_PCAPS BOOL true
append_cache_entry INSTALL_ZEEK_ARCHIVER BOOL true
append_cache_entry INSTALL_ZEEKCTL BOOL true
append_cache_entry INSTALL_ZKG BOOL true
append_cache_entry CPACK_SOURCE_IGNORE_FILES STRING
append_cache_entry ZEEK_SANITIZERS STRING ""
append_cache_entry ZEEK_SANITIZERS STRING ""
append_cache_entry ZEEK_INCLUDE_PLUGINS STRING ""
has_enable_mobile_ipv6=0
@ -179,12 +179,12 @@ has_enable_mobile_ipv6=0
# parse arguments
while [ $# -ne 0 ]; do
case "$1" in
-*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
-*=*) optarg=$(echo "$1" | sed 's/[-_a-zA-Z0-9]*=//') ;;
*) optarg= ;;
esac
case "$1" in
--help|-h)
--help | -h)
echo "${usage}" 1>&2
exit 1
;;
@ -198,110 +198,110 @@ while [ $# -ne 0 ]; do
builddir=$optarg
;;
--build-type=*)
append_cache_entry CMAKE_BUILD_TYPE STRING $optarg
append_cache_entry CMAKE_BUILD_TYPE STRING $optarg
if [ $(echo "$optarg" | tr [:upper:] [:lower:]) = "debug" ]; then
append_cache_entry ENABLE_DEBUG BOOL true
append_cache_entry ENABLE_DEBUG BOOL true
fi
;;
--generator=*)
CMakeGenerator="$optarg"
;;
--ccache)
append_cache_entry ENABLE_CCACHE BOOL true
append_cache_entry ENABLE_CCACHE BOOL true
;;
--toolchain=*)
append_cache_entry CMAKE_TOOLCHAIN_FILE PATH $optarg
append_cache_entry CMAKE_TOOLCHAIN_FILE PATH $optarg
;;
--include-plugins=*)
append_cache_entry ZEEK_INCLUDE_PLUGINS STRING $optarg
append_cache_entry ZEEK_INCLUDE_PLUGINS STRING $optarg
;;
--prefix=*)
prefix=$optarg
append_cache_entry CMAKE_INSTALL_PREFIX PATH $optarg
append_cache_entry ZEEK_ROOT_DIR PATH $optarg
append_cache_entry CMAKE_INSTALL_PREFIX PATH $optarg
append_cache_entry ZEEK_ROOT_DIR PATH $optarg
;;
--libdir=*)
append_cache_entry CMAKE_INSTALL_LIBDIR PATH $optarg
append_cache_entry CMAKE_INSTALL_LIBDIR PATH $optarg
;;
--plugindir=*)
append_cache_entry ZEEK_PLUGIN_DIR PATH $optarg
append_cache_entry ZEEK_PLUGIN_DIR PATH $optarg
;;
--python-dir=*)
append_cache_entry ZEEK_PYTHON_DIR PATH $optarg
append_cache_entry ZEEK_PYTHON_DIR PATH $optarg
;;
--python-prefix=*)
append_cache_entry ZEEK_PYTHON_PREFIX PATH $optarg
append_cache_entry ZEEK_PYTHON_PREFIX PATH $optarg
;;
--python-home=*)
append_cache_entry ZEEK_PYTHON_HOME PATH $optarg
append_cache_entry ZEEK_PYTHON_HOME PATH $optarg
;;
--scriptdir=*)
append_cache_entry ZEEK_SCRIPT_INSTALL_PATH STRING $optarg
user_set_scriptdir="true"
;;
--conf-files-dir=*)
append_cache_entry ZEEK_ETC_INSTALL_DIR PATH $optarg
append_cache_entry ZEEK_ETC_INSTALL_DIR PATH $optarg
user_set_conffilesdir="true"
;;
--localstatedir=*)
append_cache_entry ZEEK_LOCAL_STATE_DIR PATH $optarg
append_cache_entry ZEEK_LOCAL_STATE_DIR PATH $optarg
;;
--spooldir=*)
append_cache_entry ZEEK_SPOOL_DIR PATH $optarg
append_cache_entry ZEEK_SPOOL_DIR PATH $optarg
;;
--logdir=*)
append_cache_entry ZEEK_LOG_DIR PATH $optarg
append_cache_entry ZEEK_LOG_DIR PATH $optarg
;;
--mandir=*)
append_cache_entry ZEEK_MAN_INSTALL_PATH PATH $optarg
append_cache_entry ZEEK_MAN_INSTALL_PATH PATH $optarg
;;
--enable-coverage)
append_cache_entry ENABLE_COVERAGE BOOL true
append_cache_entry ENABLE_DEBUG BOOL true
append_cache_entry ENABLE_COVERAGE BOOL true
append_cache_entry ENABLE_DEBUG BOOL true
;;
--enable-fuzzers)
append_cache_entry ZEEK_ENABLE_FUZZERS BOOL true
;;
--enable-debug)
append_cache_entry ENABLE_DEBUG BOOL true
append_cache_entry ENABLE_DEBUG BOOL true
;;
--enable-mobile-ipv6)
has_enable_mobile_ipv6=1
;;
--enable-perftools)
append_cache_entry ENABLE_PERFTOOLS BOOL true
append_cache_entry ENABLE_PERFTOOLS BOOL true
;;
--enable-perftools-debug)
append_cache_entry ENABLE_PERFTOOLS BOOL true
append_cache_entry ENABLE_PERFTOOLS_DEBUG BOOL true
append_cache_entry ENABLE_PERFTOOLS BOOL true
append_cache_entry ENABLE_PERFTOOLS_DEBUG BOOL true
;;
--sanitizers=*)
append_cache_entry ZEEK_SANITIZERS STRING $optarg
append_cache_entry ZEEK_SANITIZERS STRING $optarg
;;
--enable-jemalloc)
append_cache_entry ENABLE_JEMALLOC BOOL true
append_cache_entry ENABLE_JEMALLOC BOOL true
;;
--enable-static-broker)
append_cache_entry BUILD_STATIC_BROKER BOOL true
append_cache_entry BUILD_STATIC_BROKER BOOL true
;;
--enable-static-binpac)
append_cache_entry BUILD_STATIC_BINPAC BOOL true
append_cache_entry BUILD_STATIC_BINPAC BOOL true
;;
--enable-cpp-tests)
append_cache_entry ENABLE_ZEEK_UNIT_TESTS BOOL true
append_cache_entry ENABLE_ZEEK_UNIT_TESTS BOOL true
;;
--enable-zeek-client)
append_cache_entry INSTALL_ZEEK_CLIENT BOOL true
append_cache_entry INSTALL_ZEEK_CLIENT BOOL true
;;
--disable-zeekctl)
append_cache_entry INSTALL_ZEEKCTL BOOL false
append_cache_entry INSTALL_ZEEKCTL BOOL false
;;
--disable-auxtools)
append_cache_entry INSTALL_AUX_TOOLS BOOL false
append_cache_entry INSTALL_AUX_TOOLS BOOL false
;;
--disable-archiver)
append_cache_entry INSTALL_ZEEK_ARCHIVER BOOL false
append_cache_entry INSTALL_ZEEK_ARCHIVER BOOL false
;;
--disable-btest)
append_cache_entry INSTALL_BTEST BOOL false
@ -310,10 +310,10 @@ while [ $# -ne 0 ]; do
append_cache_entry INSTALL_BTEST_PCAPS BOOL false
;;
--disable-python)
append_cache_entry DISABLE_PYTHON_BINDINGS BOOL true
append_cache_entry DISABLE_PYTHON_BINDINGS BOOL true
;;
--disable-broker-tests)
append_cache_entry BROKER_DISABLE_TESTS BOOL true
append_cache_entry BROKER_DISABLE_TESTS BOOL true
append_cache_entry BROKER_DISABLE_DOC_EXAMPLES BOOL true
;;
--disable-zkg)
@ -329,10 +329,10 @@ while [ $# -ne 0 ]; do
append_cache_entry PCAP_ROOT_DIR PATH $optarg
;;
--with-binpac=*)
append_cache_entry BINPAC_EXE_PATH PATH $optarg
append_cache_entry BINPAC_EXE_PATH PATH $optarg
;;
--with-bifcl=*)
append_cache_entry BIFCL_EXE_PATH PATH $optarg
append_cache_entry BIFCL_EXE_PATH PATH $optarg
;;
--with-flex=*)
append_cache_entry FLEX_EXECUTABLE PATH $optarg
@ -350,30 +350,30 @@ while [ $# -ne 0 ]; do
append_cache_entry GooglePerftools_ROOT_DIR PATH $optarg
;;
--with-jemalloc=*)
append_cache_entry JEMALLOC_ROOT_DIR PATH $optarg
append_cache_entry ENABLE_JEMALLOC BOOL true
append_cache_entry JEMALLOC_ROOT_DIR PATH $optarg
append_cache_entry ENABLE_JEMALLOC BOOL true
;;
--with-python=*)
append_cache_entry PYTHON_EXECUTABLE PATH $optarg
append_cache_entry PYTHON_EXECUTABLE PATH $optarg
;;
--with-python-lib=*)
append_cache_entry PYTHON_LIBRARY PATH $optarg
append_cache_entry PYTHON_LIBRARY PATH $optarg
;;
--with-python-inc=*)
append_cache_entry PYTHON_INCLUDE_DIR PATH $optarg
append_cache_entry PYTHON_INCLUDE_PATH PATH $optarg
append_cache_entry PYTHON_INCLUDE_DIR PATH $optarg
append_cache_entry PYTHON_INCLUDE_PATH PATH $optarg
;;
--with-swig=*)
append_cache_entry SWIG_EXECUTABLE PATH $optarg
append_cache_entry SWIG_EXECUTABLE PATH $optarg
;;
--with-broker=*)
append_cache_entry BROKER_ROOT_DIR PATH $optarg
append_cache_entry BROKER_ROOT_DIR PATH $optarg
;;
--with-caf=*)
append_cache_entry CAF_ROOT PATH $optarg
append_cache_entry CAF_ROOT PATH $optarg
;;
--with-libkqueue=*)
append_cache_entry LIBKQUEUE_ROOT_DIR PATH $optarg
append_cache_entry LIBKQUEUE_ROOT_DIR PATH $optarg
;;
--binary-package)
append_cache_entry BINARY_PACKAGING_MODE BOOL true
@ -400,15 +400,15 @@ done
if [ -z "$CMakeCommand" ]; then
# prefer cmake3 over "regular" cmake (cmake == cmake2 on RHEL)
if command -v cmake3 >/dev/null 2>&1 ; then
if command -v cmake3 >/dev/null 2>&1; then
CMakeCommand="cmake3"
elif command -v cmake >/dev/null 2>&1 ; then
elif command -v cmake >/dev/null 2>&1; then
CMakeCommand="cmake"
else
echo "This package requires CMake, please install it first."
echo "Then you may use this script to configure the CMake build."
echo "Note: pass --cmake=PATH to use cmake in non-standard locations."
exit 1;
exit 1
fi
fi
@ -442,8 +442,8 @@ else
"$CMakeCommand" $CMakeCacheEntries $sourcedir
fi
echo "# This is the command used to configure this build" > config.status
echo $command >> config.status
echo "# This is the command used to configure this build" >config.status
echo $command >>config.status
chmod u+x config.status
if [ $has_enable_mobile_ipv6 -eq 1 ]; then