mirror of
https://github.com/timescale/timescaledb.git
synced 2025-05-14 17:43:34 +08:00
Writing a shell script correctly can be hard even for a skilled programmer. shellcheck is a static analysis tool that helps catch common errors in shell scripts. We now have 36 executable scripts in our repository, for which shellcheck reports 126 errors (calculated like find . -type f -executable -exec bash -c '[ "$(file --brief --mime-type "$1")" == "text/x-shellscript" ]' sh {} \; -exec shellcheck -f gcc --exclude=SC2086 {} \; | cut -d: -f1 | sort | uniq | wc -l). This commit fixes these warnings and adds a GitHub actions workflow that runs shellcheck on all the executable shell scripts in the repository. The warning SC2086: Double quote to prevent globbing and word splitting is disabled globally, because it has little practical consequences, sometimes leads to false positives, and is general is too widespread because people forget to quote.
43 lines
1.1 KiB
Bash
Executable File
43 lines
1.1 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
# This bootstrap scripts set up the build environment for TimescaleDB
|
|
# Any flags will be passed on to CMake, e.g.,
|
|
# ./bootstrap -DCMAKE_BUILD_TYPE="Debug"
|
|
|
|
## Check to make cmake is installed
|
|
if ! command -v cmake >/dev/null 2>&1; then
|
|
echo "cmake is required to build TimescaleDB. Please install via your system's preferred method."
|
|
exit 1
|
|
fi
|
|
|
|
BUILD_DIR=${BUILD_DIR:-./build}
|
|
BUILD_FORCE_REMOVE=${BUILD_FORCE_REMOVE:-false}
|
|
SRC_DIR=$(dirname $0)
|
|
if [[ ! ${SRC_DIR} == /* ]]; then
|
|
SRC_DIR=$(pwd)/${SRC_DIR}
|
|
fi
|
|
|
|
if [ ${BUILD_FORCE_REMOVE} == "true" ]; then
|
|
rm -fr ${BUILD_DIR}
|
|
elif [ -d ${BUILD_DIR} ]; then
|
|
echo "Build system already initialized in ${BUILD_DIR}"
|
|
|
|
read -r -n 1 -p "Do you want to remove it (this is IMMEDIATE and PERMANENT), y/n? " choice
|
|
echo ""
|
|
if [ $choice == "y" ]; then
|
|
rm -fr ${BUILD_DIR}
|
|
else
|
|
exit
|
|
fi
|
|
fi
|
|
|
|
set -e
|
|
set -u
|
|
|
|
mkdir -p ${BUILD_DIR} && \
|
|
cd ${BUILD_DIR} && \
|
|
cmake ${SRC_DIR} "$@"
|
|
|
|
echo "TimescaleDB build system initialized in ${BUILD_DIR}. To compile, do:"
|
|
echo -e "\033[1mcd ${BUILD_DIR} && make\033[0m"
|