Fix for olllllld bash
authorBrett Parker <arch@sommitrealweird.co.uk>
Mon, 12 Sep 2005 11:28:06 +0000 (11:28 +0000)
committerBrett Parker <arch@sommitrealweird.co.uk>
Mon, 12 Sep 2005 11:28:06 +0000 (11:28 +0000)
Bash 2.05 does not include the =~ operator for regexps, so we get round this in inventive ways to overcome the shortfallings of a default debian sarge install (I really wish they'd made bash3 the default in that release!)
git-archimport-id: arch@sommitrealweird.co.uk--2005-desktop/rpmbased-dist-chroot--mainline--0.1--patch-2

rpmbased-dist-chroot.sh

index 5aaf4ea..268fd4f 100755 (executable)
@@ -43,9 +43,25 @@ END
        exit $1
 }
 
+function startswithmm() {
+       if [ "${1##--*}" == "" ]; then
+               return 0
+       else
+               return 1
+       fi
+}
+
+function containsequals() {
+       if [ "${1//*=*}" == "" ]; then
+               return 0
+       else
+               return 1
+       fi
+}
+
 argcommand=""
 for option in $@; do
-       if [[ ! $option =~ ^-- ]]; then
+       if ( ! startswithmm $option ); then
                if [ "x$argcommand" == "xinstall-root" ]; then
                        InstallRoot=$option
                elif [ "x$argcommand" == "xrpm-archives" ]; then
@@ -58,7 +74,7 @@ for option in $@; do
                        fi
                fi
        else
-               if [[ $option =~ [=] ]]; then
+               if ( containsequals $option ); then
                        argcommand=${option%%=*}
                        argcommand=${argcommand##--}
                        option=${option##*=}
@@ -198,7 +214,9 @@ done
 
 read -p "Remove cache directory ($ourcachedirectory)? [Yn]: " cleanup
 
-if [[ $cleanup =~ ^[Nn] ]]; then
+cleanup=${cleanup:0:1}
+
+if [ "$cleanup" == "N" ] || [ "$cleanup" == "n" ] ; then
        echo leaving logs in $ourcachedirectory
 else
        echo removing logs directory