aboutsummaryrefslogtreecommitdiff
path: root/scripts/pvscheck.sh
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/pvscheck.sh')
-rwxr-xr-xscripts/pvscheck.sh34
1 files changed, 18 insertions, 16 deletions
diff --git a/scripts/pvscheck.sh b/scripts/pvscheck.sh
index ca85b6be7f..dfdc539bf9 100755
--- a/scripts/pvscheck.sh
+++ b/scripts/pvscheck.sh
@@ -1,14 +1,20 @@
#!/bin/sh
+
+# Assume that "local" is available.
+# shellcheck disable=SC2039
+
set -e
# Note: -u causes problems with posh, it barks at “undefined” $@ when no
# arguments provided.
test -z "$POSH_VERSION" && set -u
get_jobs_num() {
- local num="$(cat /proc/cpuinfo | grep -c "^processor")"
- num="$(echo $(( num + 1 )))"
- num="${num:-1}"
- echo $num
+ if [ -n "${TRAVIS:-}" ] ; then
+ # HACK: /proc/cpuinfo on Travis CI is misleading, so hardcode 1.
+ echo 1
+ else
+ echo $(( $(grep -c "^processor" /proc/cpuinfo) + 1 ))
+ fi
}
help() {
@@ -21,7 +27,7 @@ help() {
echo ' --pvs: Use the specified URL as a path to pvs-studio archive.'
echo ' By default latest tested version is used.'
echo
- echo ' May use `--pvs detect` to try detecting latest version.'
+ echo ' May use "--pvs detect" to try detecting latest version.'
echo ' That assumes certain viva64.com site properties and'
echo ' may be broken by the site update.'
echo
@@ -261,15 +267,6 @@ install_pvs() {(
rmdir "$pvsdir"
)}
-adjust_path() {
- if test -d "$tgt/pvs-studio" ; then
- local saved_pwd="$PWD"
- cd "$tgt/pvs-studio"
- export PATH="$PWD/bin${PATH+:}${PATH}"
- cd "$saved_pwd"
- fi
-}
-
create_compile_commands() {(
local tgt="$1" ; shift
local deps="$1" ; shift
@@ -369,7 +366,7 @@ do_check() {
do_recheck() {
local tgt="$1" ; shift
- local deps="$2" ; shift
+ local deps="$1" ; shift
create_compile_commands "$tgt" "$deps"
@@ -379,7 +376,12 @@ do_recheck() {
do_analysis() {
local tgt="$1" ; shift
- adjust_path "$tgt"
+ if test -d "$tgt/pvs-studio" ; then
+ local saved_pwd="$PWD"
+ cd "$tgt/pvs-studio"
+ export PATH="$PWD/bin${PATH+:}${PATH}"
+ cd "$saved_pwd"
+ fi
run_analysis "$tgt"
}