From 3a4d0c9c148111a3184ebc06ab80b548135b9c77 Mon Sep 17 00:00:00 2001 From: Harald Hoyer Date: Mon, 2 Aug 2010 14:16:10 +0200 Subject: [PATCH] dracut-lib.sh: fixed getarg for nonexistent parameters getarg returned an old "$val" for nonexistent parameters, because "val" was not local --- modules.d/99base/dracut-lib.sh | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) 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; } -- 2.47.3