Make scripts/install_cppcheck.sh shellcheck-compatible

This commit is contained in:
matt335672 2024-09-02 15:36:19 +01:00
parent bc3f0e63f6
commit af22422260
1 changed files with 12 additions and 9 deletions

View File

@ -28,11 +28,11 @@ usage()
call_make() call_make()
{ {
# Disable set -e, if active # Disable set -e, if active
set_entry_opts=`set +o` set_entry_opts=$(set +o)
set +e set +e
status=1 status=1
log=`mktemp /tmp/cppcheck-log.XXXXXXXXXX` log=$(mktemp /tmp/cppcheck-log.XXXXXXXXXX)
if [ -n "$log" ]; then if [ -n "$log" ]; then
make "$@" >"$log" 2>&1 make "$@" >"$log" 2>&1
status=$? status=$?
@ -58,13 +58,15 @@ call_make()
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
create_z3_version_h() create_z3_version_h()
{ {
set -- `z3 --version` # shellcheck disable=SC2046
if [ $# != 3 -o "$1/$2" != Z3/version ]; then set -- $(z3 --version)
if [ $# != 3 ] || [ "$1/$2" != Z3/version ]; then
echo "** Unexpected output from z3 command '$*'" >&2 echo "** Unexpected output from z3 command '$*'" >&2
false false
else else
z3ver=$3 ; # e.g. 4.4.3 z3ver="$3" ; # e.g. 4.4.3
set -- `echo $z3ver | tr '.' ' '` # shellcheck disable=SC2046
set -- $(echo "$z3ver" | tr '.' ' ')
if [ $# != 3 ]; then if [ $# != 3 ]; then
echo "** Unable to determine Z3 version from '$z3ver'" >&2 echo "** Unable to determine Z3 version from '$z3ver'" >&2
false false
@ -104,7 +106,7 @@ if [ -x "$exe" ]; then
exit 0 exit 0
fi fi
workdir=`mktemp -d /tmp/cppcheck.XXXXXXXXXX` workdir=$(mktemp -d /tmp/cppcheck.XXXXXXXXXX)
if [ -z "$workdir" ]; then if [ -z "$workdir" ]; then
echo "** Unable to create temporary working directory" 2>&1 echo "** Unable to create temporary working directory" 2>&1
exit 1 exit 1
@ -154,18 +156,19 @@ fi
# Use all available CPUs # Use all available CPUs
if [ -f /proc/cpuinfo ]; then if [ -f /proc/cpuinfo ]; then
cpus=`grep ^processor /proc/cpuinfo | wc -l` cpus=$(grep -c ^processor /proc/cpuinfo)
if [ -n "$cpus" ]; then if [ -n "$cpus" ]; then
make_args="$make_args -j $cpus" make_args="$make_args -j $cpus"
fi fi
fi fi
echo "Making cppcheck..." echo "Making cppcheck..."
# CFGDIR is needed for cppcheck before 1.86 # shellcheck disable=SC2086
call_make $make_args call_make $make_args
echo "Installing cppcheck..." echo "Installing cppcheck..."
mkdir -p "$FILESDIR" mkdir -p "$FILESDIR"
# shellcheck disable=SC2086
call_make install $make_args call_make install $make_args
) )
status=$? status=$?