Bug#772410: [PATCH] Fix bashisms in scripts
On Wed, 10 Dec 2014 13:54:45 +0600 Boris Egorov ego...@linux.com 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). My patch was merged to upstream sources: http://gitweb.scilab.org/?p=scilab.git;a=commit;h=90fdeab56e36e6d7f8b1c3459ae7ea06438bef95 -- Best regards, Boris Egorov -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Bug#772410: [PATCH] Fix bashisms in scripts
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 ego...@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 -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Bug#772410: [PATCH] Fix bashisms in scripts
On 12/10/2014 05:00 PM, Sylvestre Ledru wrote: Hello Thanks but next time, you should check in the svn, most of them were already fixed :/ Oh, fine. Now I know what to do next time =) I just get upstream sources and create patch on them: http://bugzilla.scilab.org/show_bug.cgi?id=13695 I checked that line numbers in debian repo the same (apt-get source scilab) and send a patch here. -- Best Regards, Boris Egorov -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Bug#772410: [PATCH] Fix bashisms in scripts
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 ego...@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 -- 2.1.3 -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org