From: Harald Hoyer Date: Mon, 2 Aug 2010 12:16:10 +0000 (+0200) Subject: dracut-lib.sh: fixed getarg for nonexistent parameters X-Git-Tag: 007~37 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3a4d0c9c148111a3184ebc06ab80b548135b9c77;p=thirdparty%2Fdracut.git dracut-lib.sh: fixed getarg for nonexistent parameters getarg returned an old "$val" for nonexistent parameters, because "val" was not local --- diff --git a/modules.d/99base/dracut-lib.sh b/modules.d/99base/dracut-lib.sh index 54dbf3cdd..06816723d 100755 --- a/modules.d/99base/dracut-lib.sh +++ b/modules.d/99base/dracut-lib.sh @@ -6,7 +6,7 @@ strstr() { getarg() { set +x - local o line + local o line val if [ -z "$CMDLINE" ]; then if [ -e /etc/cmdline ]; then while read line; do @@ -17,10 +17,17 @@ getarg() { CMDLINE="$CMDLINE $CMDLINE_ETC" fi for o in $CMDLINE; do - [ "$o" = "$1" ] && { [ "$RDDEBUG" = "yes" ] && set -x; return 0; } + if [ "$o" = "$1" ]; then + [ "$RDDEBUG" = "yes" ] && set -x; + return 0; + fi [ "${o%%=*}" = "${1%=}" ] && val=${o#*=}; done - [ -n "$val" ] && { echo $val; [ "$RDDEBUG" = "yes" ] && set -x; return 0; } + if [ -n "$val" ]; then + echo $val; + [ "$RDDEBUG" = "yes" ] && set -x; + return 0; + fi [ "$RDDEBUG" = "yes" ] && set -x return 1 } @@ -38,13 +45,19 @@ getargs() { CMDLINE="$CMDLINE $CMDLINE_ETC" fi for o in $CMDLINE; do - [ "$o" = "$1" ] && { [ "$RDDEBUG" = "yes" ] && set -x; return 0; } + if [ "$o" = "$1" ]; then + [ "$RDDEBUG" = "yes" ] && set -x; + return 0; + fi if [ "${o%%=*}" = "${1%=}" ]; then echo -n "${o#*=} "; found=1; fi done - [ -n "$found" ] && { [ "$RDDEBUG" = "yes" ] && set -x; return 0; } + if [ -n "$found" ]; then + [ "$RDDEBUG" = "yes" ] && set -x + return 0; + fi [ "$RDDEBUG" = "yes" ] && set -x return 1; }