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>
This commit is contained in:
qarkai 2017-02-03 22:05:44 +03:00 committed by jan iversen
parent 1bdef25291
commit e6a9dc22a4
10 changed files with 67 additions and 45 deletions

View file

@ -1,4 +1,4 @@
#!/bin/sh
cmd=`dirname "$0"`/soffice
cmd=$(dirname "$0")/soffice
exec "$cmd" --base "$@"

View file

@ -1,4 +1,4 @@
#!/bin/sh
cmd=`dirname "$0"`/soffice
cmd=$(dirname "$0")/soffice
exec "$cmd" --calc "$@"

View file

@ -1,4 +1,4 @@
#!/bin/sh
cmd=`dirname "$0"`/soffice
cmd=$(dirname "$0")/soffice
exec "$cmd" --draw "$@"

View file

@ -1,4 +1,4 @@
#!/bin/sh
cmd=`dirname "$0"`/soffice
cmd=$(dirname "$0")/soffice
exec "$cmd" --impress "$@"

View file

@ -1,4 +1,4 @@
#!/bin/sh
cmd=`dirname "$0"`/soffice
cmd=$(dirname "$0")/soffice
exec "$cmd" --math "$@"

View file

@ -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" "$@"

View file

@ -1,4 +1,4 @@
#!/bin/sh
cmd=`dirname "$0"`/soffice
cmd=$(dirname "$0")/soffice
exec "$cmd" --writer "$@"

View file

@ -22,12 +22,14 @@ set -e
# resolve installation directory
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 "$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`
sd_dirname=$(dirname "$sd_res")
cd "$sd_dirname"
sd_prog=$(pwd)
case "$1" in
c++)

View file

@ -22,12 +22,14 @@ set -e
# resolve installation directory
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 "$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`
sd_dirname=$(dirname "$sd_res")
cd "$sd_dirname"
sd_prog=$(pwd)
case "$1" in
c++)

View file

@ -21,20 +21,29 @@
SAL_ENABLE_FILE_LOCKING=1
export SAL_ENABLE_FILE_LOCKING
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"
# this is a temporary hack until we can live with the default search paths
case "`uname -s`" in
case "$(uname -s)" in
NetBSD|OpenBSD|FreeBSD|DragonFly)
LD_LIBRARY_PATH="$sd_prog${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}"
JAVA_HOME=$(javaPathHelper -h libreoffice-java 2> /dev/null)
@ -49,7 +58,7 @@ AIX)
;;
esac
for arg in $@
for arg in "$@"
do
case "$arg" in
#collect all bootstrap variables specified on the command line
@ -63,10 +72,10 @@ done
# extend the ld_library_path for java: javaldx checks the sofficerc for us
if [ -x "${sd_prog}/javaldx" ] ; then
my_path=`"${sd_prog}/javaldx" $BOOTSTRAPVARS \
"-env:INIFILENAME=vnd.sun.star.pathname:$sd_prog/redirectrc"`
my_path=$("${sd_prog}/javaldx" "$BOOTSTRAPVARS" \
"-env:INIFILENAME=vnd.sun.star.pathname:$sd_prog/redirectrc")
if [ -n "$my_path" ] ; then
sd_platform=`uname -s`
sd_platform=$(uname -s)
case "$sd_platform" in
AIX)
LIBPATH="$my_path${LIBPATH:+:$LIBPATH}"
@ -91,4 +100,3 @@ unset XENVIRONMENT
# execute binary
exec "$sd_prog/unopkg.bin" "$@" \
"-env:INIFILENAME=vnd.sun.star.pathname:$sd_prog/redirectrc"