scripts: clean up various shellcheck warnings

Should hopefully not break anything :).
master
Mike Frysinger 2021-02-08 18:10:51 -05:00
parent e1f02d2833
commit c75db8d082
7 changed files with 64 additions and 63 deletions

View File

@ -9,7 +9,7 @@ v() { echo "$@"; "$@"; }
# so that random hackers don't need it just to build the code.
v docs/naturaldocs/run_docs.sh --nonfatal
if echo "${OSTYPE:-$(uname)}" | grep -q '^darwin' ; then
if uname | grep -qi '^darwin' ; then
echo "Having trouble on OS X? Try: brew install autoconf libtool automake gettext pkg-config cmake"
fi

View File

@ -12,7 +12,7 @@ Clean all the cmake generated output files.
Options:
--automake Do not clean files autotools also creates
EOF
exit ${1:-0}
exit "${1:-0}"
}
AUTOMAKE="false"

View File

@ -15,9 +15,9 @@ usage() {
nd() {
# Figure out the name of this tool.
if which naturaldocs 2>/dev/null ; then
if command -v naturaldocs >/dev/null ; then
return
elif which NaturalDocs 2>/dev/null ; then
elif command -v NaturalDocs >/dev/null ; then
return
else
return 1
@ -46,7 +46,7 @@ elif [ $# -ne 0 ] ; then
fi
# Version number
VERSION=`(cd ../../; perl config/getver.pl)`
VERSION=$(cd ../../; perl config/getver.pl)
# Clear away old docs and ensure the doc dir. is present.
rm -rf html
@ -66,11 +66,11 @@ sed -e "s/@VERSION@/$VERSION/g" preamble.txt > tmp/preamble.txt
# Run naturaldocs to create the manual.
$(nd) --rebuild --rebuild-output --documented-only \
-i tmp/ \
-img images/ \
-o html html \
--project project/ \
-s Default libgd
-i tmp/ \
-img images/ \
-o html html \
--project project/ \
-s Default libgd
# And cleanup the temp files.
rm -rf Data tmp

View File

@ -15,11 +15,10 @@ export GIT_PAGER=cat
export LC_ALL=C
# List all the non-binary files we know about in the tree.
files=".tmp.files"
trap 'rm -f "${files}"' EXIT
git ls-tree -r --name-only HEAD | \
grep -Ev '\.(bin|bmp|gd|gd2|gif|jpg|jpeg|png|pic|sgi|tga|tiff|ttf|xbm|xpm)$' \
> "${files}"
read -r -d'\n' -a files < <(
git ls-tree -r --name-only HEAD | \
grep -Ev '\.(bin|bmp|gd|gd2|gif|jpg|jpeg|png|pic|sgi|tga|tiff|ttf|xbm|xpm)$'
) || :
banner() {
echo
@ -28,7 +27,7 @@ banner() {
do_grep() {
# Use -a so UTF-8 files don't get flagged as binary & skipped.
if git grep -aHnE "$@" $(<"${files}") ; then
if git grep -aHnE "$@" "${files[@]}" ; then
ret=1
fi
}
@ -42,6 +41,6 @@ banner "Check for Windows line endings."
do_grep $'\r$'
banner "Checking trailing lines."
"${TEST_DIR}"/whitespace.py $(<"${files}")
"${TEST_DIR}"/whitespace.py "${files[@]}"
exit ${ret}

View File

@ -13,7 +13,7 @@ if [[ -n ${TRAVIS_OS_NAME} ]] ; then
normal=$(tput sgr0)
else
whitebg=
blackbg=
blackfg=
normal=
fi
v() {
@ -34,5 +34,5 @@ v() {
ncpus=$(getconf _NPROCESSORS_ONLN)
m() {
v make -j${ncpus} "$@"
v make -j"${ncpus}" "$@"
}

View File

@ -4,6 +4,7 @@
# TODO: Add support for building/testing w/ASAN/etc... enabled.
# shellcheck source=travis/lib.sh
. "${0%/*}"/lib.sh
# We have to do this by hand rather than use the coverity addon because of
@ -78,18 +79,18 @@ build_autotools() {
}
cmake_args=(
-DBUILD_SHARED_LIBS=1
-DBUILD_STATIC_LIBS=1
-DBUILD_TEST=1
-DCMAKE_INSTALL_PREFIX=/usr/local
-DCMAKE_INSTALL_LIBDIR=/usr/local/lib
-DENABLE_GD_FORMATS=1
-DENABLE_FONTCONFIG=1
-DENABLE_FREETYPE=1
-DENABLE_JPEG=1
-DENABLE_PNG=1
-DENABLE_TIFF=1
-DENABLE_WEBP=1
"-DBUILD_SHARED_LIBS=1"
"-DBUILD_STATIC_LIBS=1"
"-DBUILD_TEST=1"
"-DCMAKE_INSTALL_PREFIX=/usr/local"
"-DCMAKE_INSTALL_LIBDIR=/usr/local/lib"
"-DENABLE_GD_FORMATS=1"
"-DENABLE_FONTCONFIG=1"
"-DENABLE_FREETYPE=1"
"-DENABLE_JPEG=1"
"-DENABLE_PNG=1"
"-DENABLE_TIFF=1"
"-DENABLE_WEBP=1"
)
# libxpm-dev is unavaible in brew repo
@ -104,15 +105,15 @@ build_cmake() {
cd build
v cmake "${cmake_args[@]}" ..
m
v ctest -j${ncpus}
v ctest -j"${ncpus}"
cd ..
rm -rf build
# Then build in-tree.
v cmake "${cmake_args[@]}" .
m
v ctest -j${ncpus}
m install DESTDIR=$PWD/install-cmake
v ctest -j"${ncpus}"
m install DESTDIR="${PWD}/install-cmake"
}
compare_builds() {
@ -148,7 +149,7 @@ build_codecov() {
export CFLAGS="-fprofile-arcs -ftest-coverage"
v cmake "${cmake_args[@]}" ..
m
v ctest -j${ncpus}
v ctest -j"${ncpus}"
bash <(curl -s https://codecov.io/bash)
}

View File

@ -13,14 +13,15 @@ CFLAGS="-g -Igdtest/ -I. -I../src/ -D_WIN32 -DHAVE_SYS_STAT_H $CFLAGS_EXTRA"
LDFLAGS='-L../src -llibgd'
DLLPATH=../src:$DLLPATH_EXTRA
function run_gcc {
if msg=`gcc $* 2>&1`; then
true
else
echo "COMMAND: gcc $*" >> $LOG
echo $msg >> $LOG
false
fi
run_gcc() {
local msg
if msg=$(gcc "$@" 2>&1); then
true
else
echo "COMMAND: gcc $*" >> "${LOG}"
echo "${msg}" >> "${LOG}"
false
fi
}
# Switch to the working directory
@ -29,7 +30,7 @@ cd ../../tests
# Initial setup
echo "Setting up..."
[ -f $LOG ] && rm -f $LOG
rm -f "${LOG}"
[ -f test_config.h ] || echo '#define GDTEST_TOP_DIR "."' > test_config.h
run_gcc -c $CFLAGS gdtest/gdtest.c
@ -38,27 +39,27 @@ echo "Running tests:"
count=0
failures=0
compile_failures=0
for test in `find . -name \*.c | grep -vE '^./(fontconfig|gdtest|gdhelpers|xpm)'`; do
count=`expr $count + 1`
for test in $(find . -name '*.c' | grep -vE '^./(fontconfig|gdtest|gdhelpers|xpm)'); do
: $(( count += 1 ))
exe=${test%.c}.exe
if run_gcc -o $exe $CFLAGS $LDFLAGS $test gdtest.o; then
true;
else
echo "COMPILE_FAIL: $test"
compile_failures=`expr $compile_failures + 1`
continue
fi
exe=${test%.c}.exe
if run_gcc -o "${exe}" ${CFLAGS} ${LDFLAGS} "${test}" gdtest.o; then
true
else
echo "COMPILE_FAIL: $test"
: $(( compile_failures += 1 ))
continue
fi
echo "Running $exe:" >> $LOG
if $exe 2>&1 >> $LOG; then
echo "PASS: $test"
else
failures=`expr $failures + 1`
echo "FAIL: $test"
fi
echo >> $LOG
echo "Running $exe:" >> "${LOG}"
if $exe >> "${LOG}" 2>&1; then
echo "PASS: $test"
else
: $(( failures += 1 ))
echo "FAIL: $test"
fi
echo >> "${LOG}"
done
echo "$failures failures and $compile_failures compile failures out of $count tests."
echo "Error messages in $LOG"
echo "Error messages in ${LOG}"