summaryrefslogtreecommitdiff
path: root/desktop/scripts/soffice.sh
diff options
context:
space:
mode:
authorqarkai <qarkai@gmail.com>2017-02-03 22:05:44 +0300
committerjan iversen <jani@documentfoundation.org>2017-02-04 08:46:14 +0000
commite6a9dc22a4e58b565894f8cdb6a19755af7b14de (patch)
treedfe64e3ad007fdd9c8f46e8a9f6acdd1d08517ae /desktop/scripts/soffice.sh
parent1bdef25291dea612305fa2cb8dd806466aa97773 (diff)
tdf#105204 fix shellcheck warnings in desktop/scripts
Use $(..) instead of `..`, use && and || instead of -a and -o, double quote to prevent word splitting, handle cd failure. Change-Id: I860891323a81ac4a46c868ab028df1e1f837c115 Reviewed-on: https://gerrit.libreoffice.org/33897 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: jan iversen <jani@documentfoundation.org>
Diffstat (limited to 'desktop/scripts/soffice.sh')
-rwxr-xr-xdesktop/scripts/soffice.sh42
1 files changed, 26 insertions, 16 deletions
diff --git a/desktop/scripts/soffice.sh b/desktop/scripts/soffice.sh
index 83e22633befc..1f7d7a231770 100755
--- a/desktop/scripts/soffice.sh
+++ b/desktop/scripts/soffice.sh
@@ -39,20 +39,30 @@ export SAL_ENABLE_FILE_LOCKING
#@JITC_PROCESSOR_TYPE_EXPORT@
+cd_or_exit() {
+ if ! cd "$1"; then
+ echo "Can't cd to $1"
+ exit 1
+ fi
+}
+
# resolve installation directory
-sd_cwd=`pwd`
+sd_cwd=$(pwd)
sd_res="$0"
while [ -h "$sd_res" ] ; do
- cd "`dirname "$sd_res"`"
- sd_basename=`basename "$sd_res"`
- sd_res=`ls -l "$sd_basename" | sed "s/.*$sd_basename -> //g"`
+ sd_dirname=$(dirname "$sd_res")
+ cd_or_exit "$sd_dirname"
+ sd_basename=$(basename "$sd_res")
+ sd_res=$(ls -l "$sd_basename" | sed "s/.*$sd_basename -> //g")
done
-cd "`dirname "$sd_res"`"
-sd_prog=`pwd`
-cd "$sd_cwd"
+sd_dirname=$(dirname "$sd_res")
+cd_or_exit "$sd_dirname"
+sd_prog=$(pwd)
+cd_or_exit "$sd_cwd"
# linked build needs additional settings
if [ -e "${sd_prog}/ooenv" ] ; then
+ # shellcheck source=../../instsetoo_native/ooenv
. "${sd_prog}/ooenv"
fi
@@ -71,7 +81,7 @@ test -n "$VALGRIND" && EXTRAOPT="--valgrind"
# force the --record option if the RR variable is set
test -n "$RR" && EXTRAOPT="--record"
-for arg in $@ $EXTRAOPT ; do
+for arg in "$@" $EXTRAOPT ; do
case "$arg" in
--record)
if which rr >/dev/null 2>&1 ; then
@@ -106,11 +116,11 @@ for arg in $@ $EXTRAOPT ; do
# another valgrind tool might be forced via the environment variable
test -z "$VALGRIND" && VALGRIND="memcheck"
# --trace-children-skip is pretty useful but supported only with valgrind >= 3.6.0
- valgrind_ver=`valgrind --version | sed -e "s/valgrind-//"`
- valgrind_ver_maj=`echo $valgrind_ver | awk -F. '{ print \$1 }'`
- valgrind_ver_min=`echo $valgrind_ver | awk -F. '{ print \$2 }'`
+ valgrind_ver=$(valgrind --version | sed -e "s/valgrind-//")
+ valgrind_ver_maj=$(echo "$valgrind_ver" | awk -F. '{ print \$1 }')
+ valgrind_ver_min=$(echo "$valgrind_ver" | awk -F. '{ print \$2 }')
valgrind_skip=
- if [ "$valgrind_ver_maj" -gt 3 -o \( "$valgrind_ver_maj" -eq 3 -a "$valgrind_ver_min" -ge 6 \) ] ; then
+ if [ "$valgrind_ver_maj" -gt 3 ] || ( [ "$valgrind_ver_maj" -eq 3 ] && [ "$valgrind_ver_min" -ge 6 ] ) ; then
valgrind_skip='--trace-children-skip=*/java,*/gij'
fi
# finally set the valgrind check
@@ -137,7 +147,7 @@ if echo "$checks" | grep -q "cc" ; then
exit 1;
fi
-case "`uname -s`" in
+case "$(uname -s)" in
NetBSD|OpenBSD|DragonFly)
# this is a temporary hack until we can live with the default search paths
LD_LIBRARY_PATH="$sd_prog${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
@@ -158,14 +168,14 @@ LC_ALL="$LO_SAVE_LC_ALL"
# run soffice.bin directly when you want to get the backtrace
if [ -n "$GDBTRACECHECK" ] ; then
- exec $GDBTRACECHECK "$sd_prog/soffice.bin" "$@"
+ exec "$GDBTRACECHECK" "$sd_prog/soffice.bin" "$@"
fi
# valgrind --log-file=valgrind.log does not work well with --trace-children=yes
-if [ -n "$VALGRINDCHECK" -a -z "$VALGRIND" ] ; then
+if [ -n "$VALGRINDCHECK" ] && [ -z "$VALGRIND" ] ; then
echo "redirecting the standard and the error output to valgrind.log"
exec > valgrind.log 2>&1
fi
# oosplash does the rest: forcing pages in, javaldx etc. are
-exec $RRCHECK $VALGRINDCHECK $STRACECHECK "$sd_prog/oosplash" "$@"
+exec "$RRCHECK" "$VALGRINDCHECK" "$STRACECHECK" "$sd_prog/oosplash" "$@"