Fix portability problems in ircd-patch script.
authorMichael Poole <mdpoole@troilus.org>
Thu, 29 Dec 2005 03:41:56 +0000 (03:41 +0000)
committerMichael Poole <mdpoole@troilus.org>
Thu, 29 Dec 2005 03:41:56 +0000 (03:41 +0000)
git-svn-id: file:///home/klmitch/undernet-ircu/undernet-ircu-svn/ircu2/branches/u2_10_12_branch@1584 c9e4aea6-c8fd-4c43-8297-357d70d61c8c

ChangeLog
ircd-patch

index 090380230a90ece3d3f96cb1ea950cdc764cda69..43bc89e27a3ba76bb5a1dc3eac3e38d213c813fe 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2005-12-28  Michael Poole <mdpoole@troilus.org>
+
+       * ircd-patch: Do not use [ for test, and do not use $[] for expr.
+       (Solaris /bin/sh, among others, have problems with those.)
+
 2005-12-23  Michael Poole <mdpoole@troilus.org>
 
        * config.guess: Update to current version.
index cdfe53ae5e035283dd9d73d675b15274d9731b61..9637b89aa72ad77ccfd98932f1f660673cdcee49 100755 (executable)
@@ -17,7 +17,7 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 #
-# $Id: ircd-patch,v 1.5 2002-04-12 13:00:35 vampire Exp $
+# $Id: ircd-patch,v 1.5.2.1 2005-12-29 03:41:56 entrope Exp $
 #
 #
 # Experimental centralized patch system for ircu
@@ -48,15 +48,15 @@ done
 update_patchlist() {
        list=""
        for name in $PLIST ; do
-               [ -f $MARKS/$name ] && list="$list.$name"
+               test -f $MARKS/$name && list="$list.$name"
        done
        echo "/* This file was automatically generated by ircd-patch */" > $PLIST_FILE
        echo "#define PATCHLIST \"$list\"" >> $PLIST_FILE
        echo "Updated $PLIST_FILE"
 }
 
-[ ! -d $DIFFS ] && (echo "*** Missing $DIFFS, creating it" ; mkdir -p $DIFFS)
-[ ! -d $MARKS ] && (echo "*** Missing $MARKS, creating it" ; mkdir -p $MARKS)
+test -d $DIFFS || (echo "*** Missing $DIFFS, creating it" ; mkdir -p $DIFFS)
+test -d $MARKS || (echo "*** Missing $MARKS, creating it" ; mkdir -p $MARKS)
 
 dry_run() {
        rejects=`patch -p0 -N -t --dry-run $2 < $1 | grep "hunk FAILED" | sed -e 's/.*to file /  /;s/\.rej$//'`
@@ -66,7 +66,7 @@ dry_run() {
 patch_list() {
        echo "Available patches (* marks applied patches):"
        for name in $PLIST ; do
-               [ -f $MARKS/$name ] && echo -n " * " || echo -n "   "
+               test -f $MARKS/$name && echo -n " * " || echo -n "   "
                echo $name
        done
        echo "Done."
@@ -75,11 +75,11 @@ patch_list() {
 patch_test() {
        echo "Testing patches:"
        list="$*"
-       [ -z "$list" ] && list=$PLIST
+       test "z$list" = "z" && list=$PLIST
        for name in $list ; do
                fname=$DIFFS/$name.diff
                echo -ne "  $name\t"
-               if [ ! -f $MARKS/$name ] ; then
+               if test ! -f $MARKS/$name ; then
                        if dry_run "$fname" ; then
                                echo -n " OK"
                        else
@@ -103,19 +103,19 @@ patch_test() {
 patch_add() {
        name=$1
        fname="$DIFFS/$name.diff"
-       if [ ! -f $fname ]; then
+       if test ! -f $fname ; then
                echo "Patch $name ($fname) does not exist"
                retcode=3
                return
        fi
 
-       if [ $force -lt 2 -a -f $MARKS/$name ] ; then
+       if test $force -lt 2 -a -f $MARKS/$name ; then
                echo "Patch $name seems already applied"
                retcode=4
                return
        fi
 
-       if [ $force -lt 1 ]; then
+       if test $force -lt 1 ; then
                echo -n "Testing $fname... "
                if ! dry_run $fname ; then
                        echo "Failed (use -f to force)."
@@ -140,19 +140,19 @@ patch_add() {
 patch_del() {
        name=$1
        fname="$DIFFS/$name.diff"
-       if [ ! -f $fname ]; then
+       if test ! -f $fname ; then
                echo "Patch $name ($fname) does not exist"
                retcode=3
                return
        fi
 
-       if [ $force -lt 2 -a ! -f $MARKS/$name ] ; then
+       if test $force -lt 2 -a ! -f $MARKS/$name ; then
                echo "Patch $name doesn't seem to be applied"
                retcode=4
                return
        fi
 
-       if [ $force -lt 1 ]; then
+       if test $force -lt 1 ; then
                echo -n "Testing $fname... "
                if ! dry_run $fname -R ; then
                        echo "Failed (use -f to force)."
@@ -188,8 +188,8 @@ do_help() {
        echo "a patch is already applied."
 }
 
-while [ "$1" == "-f" ]; do
-       force=$[$force + 1]
+while test "$1" = "-f" ; do
+       force=`expr $force + 1`
        shift
 done