Skip to content

Commit

Permalink
Make scripts/install_cppcheck.sh shellcheck-compatible
Browse files Browse the repository at this point in the history
(cherry picked from commit af22422)
  • Loading branch information
matt335672 committed Sep 4, 2024
1 parent 2d8ebf4 commit 03659cf
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions scripts/install_cppcheck.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ usage()
call_make()
{
# Disable set -e, if active
set_entry_opts=`set +o`
set_entry_opts=$(set +o)
set +e

status=1
log=`mktemp /tmp/cppcheck-log.XXXXXXXXXX`
log=$(mktemp /tmp/cppcheck-log.XXXXXXXXXX)
if [ -n "$log" ]; then
make "$@" >"$log" 2>&1
status=$?
Expand All @@ -58,13 +58,15 @@ call_make()
# ----------------------------------------------------------------------------
create_z3_version_h()
{
set -- `z3 --version`
if [ $# != 3 -o "$1/$2" != Z3/version ]; then
# shellcheck disable=SC2046
set -- $(z3 --version)
if [ $# != 3 ] || [ "$1/$2" != Z3/version ]; then
echo "** Unexpected output from z3 command '$*'" >&2
false
else
z3ver=$3 ; # e.g. 4.4.3
set -- `echo $z3ver | tr '.' ' '`
z3ver="$3" ; # e.g. 4.4.3
# shellcheck disable=SC2046
set -- $(echo "$z3ver" | tr '.' ' ')
if [ $# != 3 ]; then
echo "** Unable to determine Z3 version from '$z3ver'" >&2
false
Expand Down Expand Up @@ -104,7 +106,7 @@ if [ -x "$exe" ]; then
exit 0
fi

workdir=`mktemp -d /tmp/cppcheck.XXXXXXXXXX`
workdir=$(mktemp -d /tmp/cppcheck.XXXXXXXXXX)
if [ -z "$workdir" ]; then
echo "** Unable to create temporary working directory" 2>&1
exit 1
Expand Down Expand Up @@ -151,18 +153,19 @@ fi

# Use all available CPUs
if [ -f /proc/cpuinfo ]; then
cpus=`grep ^processor /proc/cpuinfo | wc -l`
cpus=$(grep -c ^processor /proc/cpuinfo)
if [ -n "$cpus" ]; then
make_args="$make_args -j $cpus"
fi
fi

echo "Making cppcheck..."
# CFGDIR is needed for cppcheck before 1.86
# shellcheck disable=SC2086
call_make $make_args

echo "Installing cppcheck..."
mkdir -p "$FILESDIR"
# shellcheck disable=SC2086
call_make install $make_args
)
status=$?
Expand Down

0 comments on commit 03659cf

Please sign in to comment.