patch: UNIX shell script portability


Subject: patch: UNIX shell script portability
From: Kevin Vajk (kvajk@ricochet.net)
Date: Thu Mar 01 2001 - 19:57:15 CST


Tests like [ -z $foobar ] are not portable. The variable needs to
be quoted if it might be unset, like [ -z "$foobar" ]. I've included
a patch to the abiword script-generation scripts below.

Thanks!

-- 
- Kevin Vajk
  <kvajk@ricochet.net>

Index: abi/src/pkg/common/unix/data/tbz_install.sh =================================================================== RCS file: /cvsroot/abi/src/pkg/common/unix/data/tbz_install.sh,v retrieving revision 1.2 diff -u -u -r1.2 tbz_install.sh --- abi/src/pkg/common/unix/data/tbz_install.sh 2000/10/10 00:39:30 1.2 +++ abi/src/pkg/common/unix/data/tbz_install.sh 2001/03/02 01:25:23 @@ -186,19 +186,19 @@ #now try to guess locale locale=\$LC_ALL #it's incorrect to set this variable, but someone #might set it incorrectly. -if [ -z \$locale ] +if [ -z "\$locale" ] then locale=\$LANG fi

-if [ ! -z \$locale ] +if [ ! -z "\$locale" ] then #now guess encoding encoding=\`echo \$locale | sed -e 's/^.*\.\(.*\)\$/\1/'\` - if [ ! -z \$encoding ] + if [ ! -z "\$encoding" ] then addfontdir=\$ABISUITE_FONT_HOME/\$encoding - if [ ! -z \$addfontdir ] + if [ ! -z "\$addfontdir" ] then if [ -d \$addfontdir ] then Index: abi/src/pkg/common/unix/data/tgz_install.sh =================================================================== RCS file: /cvsroot/abi/src/pkg/common/unix/data/tgz_install.sh,v retrieving revision 1.6 diff -u -u -r1.6 tgz_install.sh --- abi/src/pkg/common/unix/data/tgz_install.sh 2000/10/10 00:39:30 1.6 +++ abi/src/pkg/common/unix/data/tgz_install.sh 2001/03/02 01:25:24 @@ -186,19 +186,19 @@ #now try to guess locale locale=\$LC_ALL #it's incorrect to set this variable, but someone #might set it incorrectly. -if [ -z \$locale ] +if [ -z "\$locale" ] then locale=\$LANG fi

-if [ ! -z \$locale ] +if [ ! -z "\$locale" ] then #now guess encoding encoding=\`echo \$locale | sed -e 's/^.*\.\(.*\)\$/\1/'\` - if [ ! -z \$encoding ] + if [ ! -z "\$encoding" ] then addfontdir=\$ABISUITE_FONT_HOME/\$encoding - if [ ! -z \$addfontdir ] + if [ ! -z "\$addfontdir" ] then if [ -d \$addfontdir ] then Index: abi/src/pkg/common/unix/scripts/makewrapper.sh =================================================================== RCS file: /cvsroot/abi/src/pkg/common/unix/scripts/makewrapper.sh,v retrieving revision 1.9 diff -u -u -r1.9 makewrapper.sh --- abi/src/pkg/common/unix/scripts/makewrapper.sh 2000/10/10 00:39:31 1.9 +++ abi/src/pkg/common/unix/scripts/makewrapper.sh 2001/03/02 01:25:24 @@ -61,19 +61,19 @@ #now try to guess locale locale=\$LC_ALL #it's incorrect to set this variable, but someone #might set it incorrectly. -if [ -z \$locale ] +if [ -z "\$locale" ] then locale=\$LANG fi

-if [ ! -z \$locale ] +if [ ! -z "\$locale" ] then #now guess encoding encoding=\`echo \$locale | sed -e 's/^.*\.\(.*\)\$/\1/'\` - if [ ! -z \$encoding ] + if [ ! -z "\$encoding" ] then addfontdir=\$ABISUITE_FONT_HOME/\$encoding - if [ ! -z \$addfontdir ] + if [ ! -z "\$addfontdir" ] then if [ -d \$addfontdir ] then @@ -107,7 +107,7 @@ exit fi #Check to make sure we don't stomp on anything -if [ -z \$currentFonts ] +if [ -z "\$currentFonts" ] then # Set post run-time font path if [ -d \$ABISUITE_FONT_HOME ]



This archive was generated by hypermail 2b25 : Thu Mar 01 2001 - 19:55:19 CST