[Libreoffice-commits] core.git: desktop/scripts
qarkai
qarkai at gmail.com
Sat Feb 4 08:46:49 UTC 2017
desktop/scripts/sbase.sh | 2 -
desktop/scripts/scalc.sh | 2 -
desktop/scripts/sdraw.sh | 2 -
desktop/scripts/simpress.sh | 2 -
desktop/scripts/smath.sh | 2 -
desktop/scripts/soffice.sh | 42 +++++++++++++++++++++++++----------------
desktop/scripts/swriter.sh | 2 -
desktop/scripts/unoinfo-mac.sh | 12 ++++++-----
desktop/scripts/unoinfo.sh | 12 ++++++-----
desktop/scripts/unopkg.sh | 34 ++++++++++++++++++++-------------
10 files changed, 67 insertions(+), 45 deletions(-)
New commits:
commit e6a9dc22a4e58b565894f8cdb6a19755af7b14de
Author: qarkai <qarkai at gmail.com>
Date: Fri Feb 3 22:05:44 2017 +0300
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 at libreoffice.org>
Reviewed-by: jan iversen <jani at documentfoundation.org>
diff --git a/desktop/scripts/sbase.sh b/desktop/scripts/sbase.sh
index e3a8ed0..82e5e4b 100755
--- a/desktop/scripts/sbase.sh
+++ b/desktop/scripts/sbase.sh
@@ -1,4 +1,4 @@
#!/bin/sh
-cmd=`dirname "$0"`/soffice
+cmd=$(dirname "$0")/soffice
exec "$cmd" --base "$@"
diff --git a/desktop/scripts/scalc.sh b/desktop/scripts/scalc.sh
index c9c3cde..ff3d597 100755
--- a/desktop/scripts/scalc.sh
+++ b/desktop/scripts/scalc.sh
@@ -1,4 +1,4 @@
#!/bin/sh
-cmd=`dirname "$0"`/soffice
+cmd=$(dirname "$0")/soffice
exec "$cmd" --calc "$@"
diff --git a/desktop/scripts/sdraw.sh b/desktop/scripts/sdraw.sh
index 4131a25..9f7c1e4 100755
--- a/desktop/scripts/sdraw.sh
+++ b/desktop/scripts/sdraw.sh
@@ -1,4 +1,4 @@
#!/bin/sh
-cmd=`dirname "$0"`/soffice
+cmd=$(dirname "$0")/soffice
exec "$cmd" --draw "$@"
diff --git a/desktop/scripts/simpress.sh b/desktop/scripts/simpress.sh
index d78ea14..a1808c3 100755
--- a/desktop/scripts/simpress.sh
+++ b/desktop/scripts/simpress.sh
@@ -1,4 +1,4 @@
#!/bin/sh
-cmd=`dirname "$0"`/soffice
+cmd=$(dirname "$0")/soffice
exec "$cmd" --impress "$@"
diff --git a/desktop/scripts/smath.sh b/desktop/scripts/smath.sh
index 454fa13..9c05223 100755
--- a/desktop/scripts/smath.sh
+++ b/desktop/scripts/smath.sh
@@ -1,4 +1,4 @@
#!/bin/sh
-cmd=`dirname "$0"`/soffice
+cmd=$(dirname "$0")/soffice
exec "$cmd" --math "$@"
diff --git a/desktop/scripts/soffice.sh b/desktop/scripts/soffice.sh
index 83e2263..1f7d7a23 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" "$@"
diff --git a/desktop/scripts/swriter.sh b/desktop/scripts/swriter.sh
index 3fa48c0..19a7c9e 100755
--- a/desktop/scripts/swriter.sh
+++ b/desktop/scripts/swriter.sh
@@ -1,4 +1,4 @@
#!/bin/sh
-cmd=`dirname "$0"`/soffice
+cmd=$(dirname "$0")/soffice
exec "$cmd" --writer "$@"
diff --git a/desktop/scripts/unoinfo-mac.sh b/desktop/scripts/unoinfo-mac.sh
index ca15291..ba9dcf7 100755
--- a/desktop/scripts/unoinfo-mac.sh
+++ b/desktop/scripts/unoinfo-mac.sh
@@ -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++)
diff --git a/desktop/scripts/unoinfo.sh b/desktop/scripts/unoinfo.sh
index bf5b14f..4e66062 100755
--- a/desktop/scripts/unoinfo.sh
+++ b/desktop/scripts/unoinfo.sh
@@ -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++)
diff --git a/desktop/scripts/unopkg.sh b/desktop/scripts/unopkg.sh
index 18d0a73..c66da9b 100755
--- a/desktop/scripts/unopkg.sh
+++ b/desktop/scripts/unopkg.sh
@@ -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"
-
More information about the Libreoffice-commits
mailing list