]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
dracut-lib.sh: getarg() returns the value of the last argument
authorHarald Hoyer <harald@redhat.com>
Mon, 12 Jul 2010 16:52:44 +0000 (18:52 +0200)
committerHarald Hoyer <harald@redhat.com>
Mon, 12 Jul 2010 16:52:44 +0000 (18:52 +0200)
a=0 a=1 a=2
$(getarg a) == "2"

modules.d/99base/dracut-lib.sh

index 2624f7dbf7f7f7e0476630682ad3d3020aeed448..8fbee70c52f603a208f169a4304289c792746676 100755 (executable)
@@ -18,8 +18,9 @@ getarg() {
     fi
     for o in $CMDLINE; do
        [ "$o" = "$1" ] && { [ "$RDDEBUG" = "yes" ] && set -x; return 0; }
-       [ "${o%%=*}" = "${1%=}" ] && { echo ${o#*=}; [ "$RDDEBUG" = "yes" ] && set -x; return 0; }
+        [ "${o%%=*}" = "${1%=}" ] && val=${o#*=};
     done
+    [ -n "$val" ] && { echo $val; [ "$RDDEBUG" = "yes" ] && set -x; return 0; }
     [ "$RDDEBUG" = "yes" ] && set -x 
     return 1
 }