You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
78 lines
2.1 KiB
Bash
78 lines
2.1 KiB
Bash
9 years ago
|
#!/usr/bin/env bash
|
||
|
# vim:ts=4:sts=4:sw=4:et
|
||
|
#
|
||
|
# Author: Hari Sekhon
|
||
|
# Date: 2015-05-25 01:38:24 +0100 (Mon, 25 May 2015)
|
||
|
#
|
||
2 years ago
|
# https://github.com/HariSekhon/DevOps-Bash-tools
|
||
9 years ago
|
#
|
||
|
# License: see accompanying Hari Sekhon LICENSE file
|
||
|
#
|
||
|
# If you're using my code you're welcome to connect with me on LinkedIn and optionally send me feedback to help improve or steer this or other code I publish
|
||
|
#
|
||
2 years ago
|
# https://www.linkedin.com/in/HariSekhon
|
||
9 years ago
|
#
|
||
|
|
||
7 years ago
|
set -euo pipefail
|
||
9 years ago
|
[ -n "${DEBUG:-}" ] && set -x
|
||
3 years ago
|
srcdir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||
9 years ago
|
|
||
5 years ago
|
# shellcheck source=lib/utils.sh
|
||
5 years ago
|
. "$srcdir/lib/utils.sh"
|
||
9 years ago
|
|
||
4 years ago
|
set +o pipefail
|
||
3 years ago
|
filelist="$(find "${1:-.}" -maxdepth 2 -type f -iname '*.pl' -o \
|
||
|
-type f -iname '*.pm' -o \
|
||
|
-type f -iname '*.t' |
|
||
|
grep -v /templates/ | sort)"
|
||
4 years ago
|
set -o pipefail
|
||
5 years ago
|
|
||
|
if [ -z "$filelist" ]; then
|
||
8 years ago
|
return 0 &>/dev/null || :
|
||
8 years ago
|
exit 0
|
||
|
fi
|
||
|
|
||
9 years ago
|
section "Perl Syntax Checks"
|
||
7 years ago
|
|
||
|
start_time="$(start_timer)"
|
||
9 years ago
|
|
||
3 years ago
|
if ! type -P perl &>/dev/null; then
|
||
|
echo "Perl is not installed, skipping checks"
|
||
|
exit 0
|
||
|
fi
|
||
|
|
||
|
type -P perl
|
||
|
perl --version
|
||
|
echo
|
||
|
|
||
7 years ago
|
if [ -n "${NOSYNTAXCHECK:-}" ]; then
|
||
5 years ago
|
echo "\$NOSYNTAXCHECK environment variable set, skipping perl syntax checks"
|
||
7 years ago
|
echo
|
||
7 years ago
|
elif [ -n "${QUICK:-}" ]; then
|
||
5 years ago
|
echo "\$QUICK environment variable set, skipping perl syntax checks"
|
||
7 years ago
|
echo
|
||
7 years ago
|
else
|
||
7 years ago
|
max_len=0
|
||
|
for x in $filelist; do
|
||
|
if [ ${#x} -gt $max_len ]; then
|
||
|
max_len=${#x}
|
||
|
fi
|
||
|
done
|
||
|
# to account for the semi colon
|
||
5 years ago
|
((max_len + 1))
|
||
5 years ago
|
for filename in $filelist; do
|
||
|
isExcluded "$filename" && continue
|
||
|
printf "%-${max_len}s " "$filename:"
|
||
|
#$perl -Tc $I_lib $filename
|
||
7 years ago
|
# -W too noisy
|
||
5 years ago
|
# -Mstrict - flags common DESCRIPTION / VERSION unscoped
|
||
|
# -Mdiagnostics
|
||
5 years ago
|
# shellcheck disable=SC2154
|
||
|
# $perl is set in perl.sh which is included from utils.sh
|
||
5 years ago
|
$perl -I . -Tc "$filename" 2>&1 | sed "s,^$filename ,,"
|
||
7 years ago
|
done
|
||
7 years ago
|
time_taken "$start_time"
|
||
7 years ago
|
section2 "All Perl programs passed syntax check"
|
||
7 years ago
|
fi
|
||
9 years ago
|
echo
|