build: Fix shellcheck warnings in various old build and test scripts

Most of these scripts can probably just be deleted (see issue #2045),
but for now it was easier to just mechanically fix the shellcheck
warnings in them, rather than think about whether we actually needed the
script.

Fixes done using shellcheck 0.7.0 with default options. I haven’t tested
any of the changes.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
This commit is contained in:
Philip Withnall 2020-02-25 11:47:46 +00:00
parent 00dfb1de0f
commit c5d661b4c4
5 changed files with 40 additions and 40 deletions

View File

@ -7,22 +7,22 @@ else
exit 1 exit 1
fi fi
if test -f $ORIGINAL/lib/localcharset.c ; then : ; else if test -f "${ORIGINAL}/lib/localcharset.c" ; then : ; else
echo "Usage: make-patch.sh /path/to/libcharset" 1>&2 echo "Usage: make-patch.sh /path/to/libcharset" 1>&2
exit 1 exit 1
fi fi
VERSION=`grep VERSION= $ORIGINAL/configure.ac | sed s/VERSION=//` VERSION=$(grep VERSION= "${ORIGINAL}/configure.ac" | sed s/VERSION=//)
echo "# Patch against libcharset version $VERSION" > libcharset-glib.patch echo "# Patch against libcharset version ${VERSION}" > libcharset-glib.patch
for i in localcharset.c ref-add.sin ref-del.sin ; do for i in localcharset.c ref-add.sin ref-del.sin ; do
diff -u $ORIGINAL/lib/$i $i >> libcharset-glib.patch diff -u "${ORIGINAL}/lib/${i}" "${i}" >> libcharset-glib.patch
done done
for i in glibc21.m4 codeset.m4 ; do for i in glibc21.m4 codeset.m4 ; do
diff -u $ORIGINAL/m4/$i $i >> libcharset-glib.patch diff -u "${ORIGINAL}/m4/${i}" "${i}" >> libcharset-glib.patch
done done
diff -u $ORIGINAL/include/libcharset.h.in libcharset.h >> libcharset-glib.patch diff -u "${ORIGINAL}/include/libcharset.h.in" libcharset.h >> libcharset-glib.patch
diff -u $ORIGINAL/include/localcharset.h.in localcharset.h >> libcharset-glib.patch diff -u "${ORIGINAL}/include/localcharset.h.in" localcharset.h >> libcharset-glib.patch

View File

@ -7,27 +7,27 @@ else
exit 1 exit 1
fi fi
if test -f $ORIGINAL/lib/localcharset.c ; then : ; else if test -f "${ORIGINAL}/lib/localcharset.c" ; then : ; else
echo "Usage: update.sh /path/to/libcharset" 1>&2 echo "Usage: update.sh /path/to/libcharset" 1>&2
exit 1 exit 1
fi fi
VERSION=`grep VERSION= $ORIGINAL/configure.ac | sed s/VERSION=//` VERSION=$(grep VERSION= "${ORIGINAL}/configure.ac" | sed s/VERSION=//)
for i in localcharset.c ref-add.sin ref-del.sin config.charset ; do for i in localcharset.c ref-add.sin ref-del.sin config.charset ; do
cp $ORIGINAL/lib/$i . cp "${ORIGINAL}/lib/${i}" .
done done
for i in libcharset.h localcharset.h ; do for i in libcharset.h localcharset.h ; do
cp $ORIGINAL/include/$i.in ./$i cp "${ORIGINAL}/include/${i}.in" "./${i}"
done done
for i in codeset.m4 glibc21.m4 ; do for i in codeset.m4 glibc21.m4 ; do
cp $ORIGINAL/m4/$i . cp "${ORIGINAL}/m4/${i}" .
done done
patch -p0 < libcharset-glib.patch patch -p0 < libcharset-glib.patch
echo "dnl From libcharset $VERSION" > ../../aclibcharset.m4 echo "dnl From libcharset ${VERSION}" > ../../aclibcharset.m4

View File

@ -1,9 +1,11 @@
#! /bin/sh #! /bin/sh
set -e
IN="../update-pcre" IN="../update-pcre"
PCRE=$1 PCRE=$1
if [ "x$PCRE" = x -o "x$PCRE" = x--help -o "x$PCRE" = x-h ]; then if [ "x$PCRE" = x ] || [ "x$PCRE" = x--help ] || [ "x$PCRE" = x-h ]; then
cat >&2 << EOF cat >&2 << EOF
$0 PCRE-DIR $0 PCRE-DIR
@ -23,8 +25,8 @@ if [ ! -f gregex.h ]; then
exit 1 exit 1
fi fi
if [ ! -f $PCRE/Makefile.in -o ! -f $PCRE/pcre_compile.c ]; then if [ ! -f "${PCRE}/Makefile.in" ] || [ ! -f "${PCRE}/pcre_compile.c" ]; then
echo "'$PCRE' does not contain a valid PCRE version." 2> /dev/null echo "'${PCRE}' does not contain a valid PCRE version." 2> /dev/null
exit 1 exit 1
fi fi
@ -40,7 +42,7 @@ cd pcre
# this could be a problem (e.g. when cross-compiling), so now generate # this could be a problem (e.g. when cross-compiling), so now generate
# the file and then distribuite it with GRegex. # the file and then distribuite it with GRegex.
echo "Generating pcre_chartables.c" echo "Generating pcre_chartables.c"
cp -R $PCRE tmp-build cp -R "${PCRE}" tmp-build
cd tmp-build cd tmp-build
./configure --enable-utf8 --enable-unicode-properties --disable-cpp > /dev/null ./configure --enable-utf8 --enable-unicode-properties --disable-cpp > /dev/null
make pcre_chartables.c > /dev/null make pcre_chartables.c > /dev/null
@ -55,14 +57,14 @@ rm -R tmp-build
# Compiled C files. # Compiled C files.
echo "Generating makefiles" echo "Generating makefiles"
all_files=`awk '/^OBJ = /, /^\\s*$/ \ all_files=$(awk '/^OBJ = /, /^\\s*$/ ' \
{ \ '{' \
sub("^OBJ = ", ""); \ 'sub("^OBJ = ", "");' \
sub(".@OBJEXT@[[:blank:]]*\\\\\\\\", ""); \ 'sub(".@OBJEXT@[[:blank:]]*\\\\\\\\", "");' \
sub("\\\\$\\\\(POSIX_OBJ\\\\)", ""); \ 'sub("\\\\$\\\\(POSIX_OBJ\\\\)", "");' \
print; \ 'print;' \
}' \ '}' \
$PCRE/Makefile.in` "${PCRE}/Makefile.in")
# Headers. # Headers.
included_files="pcre.h pcre_internal.h ucp.h ucpinternal.h" included_files="pcre.h pcre_internal.h ucp.h ucpinternal.h"
@ -71,21 +73,21 @@ included_files="pcre.h pcre_internal.h ucp.h ucpinternal.h"
cat $IN/Makefile.am-1 > Makefile.am cat $IN/Makefile.am-1 > Makefile.am
for name in $all_files; do for name in $all_files; do
echo " $name.c \\" >> Makefile.am echo " $name.c \\" >> Makefile.am
if [ $name != pcre_chartables ]; then if [ "${name}" != pcre_chartables ]; then
# pcre_chartables.c is a generated file. # pcre_chartables.c is a generated file.
cp $PCRE/$name.c . cp "${PCRE}/${name}.c" .
fi fi
done done
for f in $included_files; do for f in $included_files; do
echo " $f \\" >> Makefile.am echo " $f \\" >> Makefile.am
cp $PCRE/$f . cp "${PCRE}/${f}" .
done done
cat $IN/Makefile.am-2 >> Makefile.am cat $IN/Makefile.am-2 >> Makefile.am
echo "Patching PCRE" echo "Patching PCRE"
# Copy the license. # Copy the license.
cp $PCRE/COPYING . cp "${PCRE}/COPYING" .
# Use glib for memory allocation. # Use glib for memory allocation.
patch > /dev/null < $IN/memory.patch patch > /dev/null < $IN/memory.patch

View File

@ -38,7 +38,7 @@ if ! type gdb >/dev/null 2>&1; then
fi fi
echo_v "Running gdb on assert-msg-test" echo_v "Running gdb on assert-msg-test"
OUT=$($LIBTOOL --mode=execute gdb --batch -x ${srcdir:-.}/assert-msg-test.gdb ./assert-msg-test 2> $error_out) || fail "failed to run gdb" OUT=$($LIBTOOL --mode=execute gdb --batch -x "${srcdir:-.}/assert-msg-test.gdb" ./assert-msg-test 2> $error_out) || fail "failed to run gdb"
echo_v "Checking if assert message is in __glib_assert_msg" echo_v "Checking if assert message is in __glib_assert_msg"
if ! echo "$OUT" | grep -q '^$1.*"GLib:ERROR:.*assert-msg-test.c:.*:.*main.*: assertion failed: (42 < 0)"'; then if ! echo "$OUT" | grep -q '^$1.*"GLib:ERROR:.*assert-msg-test.c:.*:.*main.*: assertion failed: (42 < 0)"'; then

View File

@ -13,25 +13,23 @@ echo_v ()
fi fi
} }
error_out=/dev/null
if [ "$1" = "-v" ]; then if [ "$1" = "-v" ]; then
verbose=1 verbose=1
error_out=/dev/stderr
fi fi
for I in ${srcdir:-.}/collate/*.in; do for I in "${srcdir:-.}"/collate/*.in; do
echo_v "Sorting $I" echo_v "Sorting $I"
name=`basename $I .in` name=$(basename "${I}" .in)
./unicode-collate $I > collate.out ./unicode-collate "${I}" > collate.out
if [ $? -eq 2 ]; then if [ $? -eq 2 ]; then
exit 0 exit 0
fi fi
diff collate.out ${srcdir:-.}/collate/$name.unicode || diff collate.out "${srcdir:-.}/collate/$name.unicode" ||
fail "unexpected error when using g_utf8_collate() on $I" fail "unexpected error when using g_utf8_collate() on $I"
./unicode-collate --key $I > collate.out ./unicode-collate --key "${I}" > collate.out
diff collate.out ${srcdir:-.}/collate/$name.unicode || diff collate.out "${srcdir:-.}/collate/$name.unicode" ||
fail "unexpected error when using g_utf8_collate_key() on $I" fail "unexpected error when using g_utf8_collate_key() on $I"
./unicode-collate --file $I > collate.out ./unicode-collate --file "${I}" > collate.out
diff collate.out ${srcdir:-.}/collate/$name.file || diff collate.out "${srcdir:-.}/collate/$name.file" ||
fail "unexpected error when using g_utf8_collate_key_for_filename() on $I" fail "unexpected error when using g_utf8_collate_key_for_filename() on $I"
done done