[Runtime] Fix pal_loader bash script for shellcheck

This commit is contained in:
Isaku Yamahata
2020-01-22 02:41:22 -08:00
committed by Dmitrii Kuvaiskii
parent 8db9c73431
commit 43ef9982e2
+15 -10
View File
@@ -17,18 +17,18 @@ do
shift
done
RUNTIME_DIR=$(/usr/bin/dirname $(readlink -f ${BASH_SOURCE[0]}))
if [ -z $PAL_HOST ]; then
RUNTIME_DIR=$(/usr/bin/dirname "$(readlink -f "${BASH_SOURCE[0]}")")
if [ -z "$PAL_HOST" ]; then
if [ ! -f /usr/bin/make ]; then
libpal="$RUNTIME_DIR/libpal-*.so"
libpal="$(echo -n $libpal)"
libpal="$(echo -n "$libpal")"
libpal="${libpal//$RUNTIME_DIR\//}"
if [ "$libpal" = 'libpal-*.so' ]; then
echo "Unable to detect PAL_HOST. Please install the make program."
exit 1
fi
array=($libpal)
array=("$libpal")
if [ ${#array[@]} -ne 1 ]; then
echo "Multiple libpal detected ($libpal). Please explicitly set the environment variable PAL_HOST."
exit 1
@@ -47,24 +47,25 @@ PAL_CMD=$RUNTIME_DIR/pal-$PAL_HOST
if [ "$GDB" == "1" ]; then
GDB=$RUNTIME_DIR/pal_gdb-$PAL_HOST
if [ ! -f $GDB ]; then
if [ ! -f "$GDB" ]; then
GDB="/usr/bin/gdb"
fi
fi
if [ "$GDB" != "" ] && [ "$GDB" != "0" ]; then
PREFIX=("$GDB")
if [ -n "$INSIDE_EMACS" ]; then
GDB="$GDB -i=mi"
PREFIX+=("-i=mi")
fi
PREFIX="$GDB --args"
PREFIX+=("--args")
fi
if [ "$PERF" == "1" ]; then
PREFIX="perf stat"
PREFIX=(perf stat)
fi
if [ "$MEMUSG" == "1" ]; then
PREFIX="$RUNTIME_DIR/../Scripts/memusg"
PREFIX=("$RUNTIME_DIR/../Scripts/memusg")
fi
while [ "$1" != "" ];
@@ -83,4 +84,8 @@ if [ ! -f "$PAL_CMD" ]; then
exit 1
fi
exec $PREFIX $PAL_CMD $MANIFEST "$@"
if [ ${#PREIFX[@]} -eq 0 ]; then
exec "$PAL_CMD" "$MANIFEST" "$@"
else
exec "${PREFIX[@]}" "$PAL_CMD" "$MANIFEST" "$@"
fi