Bug#772410: [PATCH] Fix bashisms in scripts
Sylvestre Ledru
sylvestre at debian.org
Wed Dec 10 11:00:54 UTC 2014
Hello
Thanks but next time, you should check in the svn, most of them were
already fixed :/
S
On 10/12/2014 08:54, Boris Egorov wrote:
> Do not use bash-specific features in scripts with '#!/bin/sh'
> interpreter; it can be some other shell instead of bash.
>
> Exit codes converted to non-negative values identical to those before
> (to not break some scripts relying on old behavior).
>
> Implementation of $RANDOM taken from Debian package apt script
> (apt.cron.daily).
>
> Fixes: https://bugs.debian.org/772410
> Signed-off-by: Boris Egorov <egorov at linux.com>
> ---
> scilab/bin/scilab | 4 ++--
> scilab/config/install-sh | 4 ++++
> scilab/modules/dynamic_link/src/scripts/install-sh | 4 ++++
> scilab/modules/dynamic_link/src/scripts/scicompile.sh | 6 +++---
> scilab/modules/helptools/src/script/dispatchHelp.sh | 2 +-
> 5 files changed, 14 insertions(+), 6 deletions(-)
>
> diff --git a/scilab/bin/scilab b/scilab/bin/scilab
> index 0b77b6c..cbfe5a8 100755
> --- a/scilab/bin/scilab
> +++ b/scilab/bin/scilab
> @@ -50,7 +50,7 @@ if test -n "$SCI"; then
> if test ! -d "$SCI/modules"; then
> echo "Cannot find directory $SCI/modules/ !"
> echo "SCI should point to the root data directory of Scilab"
> - exit -1
> + exit 255
> fi
> fi
>
> @@ -814,7 +814,7 @@ case $OS in
> # When started as an Application, the default path was "/"
> # It is not really useful. Changing to HOME.
> # See bugs 8339 and 10575 for rational
> - if test "$(pwd)" == "/"; then
> + if test "$(pwd)" = "/"; then
> cd $HOME
> fi
>
> diff --git a/scilab/config/install-sh b/scilab/config/install-sh
> index 377bb86..ba479c1 100755
> --- a/scilab/config/install-sh
> +++ b/scilab/config/install-sh
> @@ -345,6 +345,10 @@ do
> # is incompatible with FreeBSD 'install' when (umask & 300) != 0.
> ;;
> *)
> + if [ -z "$RANDOM" ] ; then
> + # A fix for shells that do not have this bash feature
> + RANDOM=$(( $(dd if=/dev/urandom bs=2 count=1 2> /dev/null | cksum | cut -d' ' -f1) % 32767 ))
> + fi
> tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
> trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0
>
> diff --git a/scilab/modules/dynamic_link/src/scripts/install-sh b/scilab/modules/dynamic_link/src/scripts/install-sh
> index 377bb86..ba479c1 100755
> --- a/scilab/modules/dynamic_link/src/scripts/install-sh
> +++ b/scilab/modules/dynamic_link/src/scripts/install-sh
> @@ -345,6 +345,10 @@ do
> # is incompatible with FreeBSD 'install' when (umask & 300) != 0.
> ;;
> *)
> + if [ -z "$RANDOM" ] ; then
> + # A fix for shells that do not have this bash feature
> + RANDOM=$(( $(dd if=/dev/urandom bs=2 count=1 2> /dev/null | cksum | cut -d' ' -f1) % 32767 ))
> + fi
> tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
> trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0
>
> diff --git a/scilab/modules/dynamic_link/src/scripts/scicompile.sh b/scilab/modules/dynamic_link/src/scripts/scicompile.sh
> index 9426218..694761f 100755
> --- a/scilab/modules/dynamic_link/src/scripts/scicompile.sh
> +++ b/scilab/modules/dynamic_link/src/scripts/scicompile.sh
> @@ -18,13 +18,13 @@ ORIGINALLIBNAME=libsciexternal
>
> if test ! -s Makefile.orig; then
> echo "The compiler detection has been performed. Please launch compilerDetection.sh before."
> - exit -1
> + exit 255
> fi
>
> # Check number of parameters
> if test $# -lt 2; then
> echo "Syntax : $0 libname sources"
> - exit -2
> + exit 254
> fi
>
> # retrieve parameters
> @@ -38,7 +38,7 @@ for file in $SOURCES_TEMP; do
> FFILE=`echo $file|sed -e 's|\.o$|\.f|g'`
> if [ ! -s $file -a -s $CFILE -a -s $FFILE ]; then
> echo "Error: Cannot find $file"
> - exit -3
> + exit 253
> fi
> # It is an include file, do not build it!
> if [ ! `echo $file|grep -i -E "(\.h$|\.hh$|\.hxx$|\.H$)"` ]; then
> diff --git a/scilab/modules/helptools/src/script/dispatchHelp.sh b/scilab/modules/helptools/src/script/dispatchHelp.sh
> index 987eb45..e8ee6e8 100644
> --- a/scilab/modules/helptools/src/script/dispatchHelp.sh
> +++ b/scilab/modules/helptools/src/script/dispatchHelp.sh
> @@ -5,7 +5,7 @@
>
> if test -z "$SCI"; then
> echo "Please define the variable SCI"
> - exit -2
> + exit 254
> fi
>
> REFERENCE_LANG=en_US
More information about the debian-science-maintainers
mailing list