From: Harald Hoyer Date: Wed, 20 Jul 2011 19:12:17 +0000 (+0200) Subject: dracut-lib.sh: fixed getargs() X-Git-Tag: 012~63 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9e7f4955895c1064e3bdd03f5f781efc9b98d5d6;p=thirdparty%2Fdracut.git dracut-lib.sh: fixed getargs() if $1 has a "=", we want the exact match if cmdline argument has no "=", we assume "=1" --- diff --git a/modules.d/99base/dracut-lib.sh b/modules.d/99base/dracut-lib.sh index 10025bdbb..c2202f127 100755 --- a/modules.d/99base/dracut-lib.sh +++ b/modules.d/99base/dracut-lib.sh @@ -45,19 +45,36 @@ _getcmdline() { } _dogetarg() { - local _o _val + local _o _val _doecho unset _val unset _o + unset _doecho _getcmdline for _o in $CMDLINE; do - if [ "$_o" = "$1" ]; then - return 0; + if [ "${_o%%=*}" = "${1%=}" ]; then + if [ -n "${1#*=}" -a "${1#*=*}" != "${1}" ]; then + # if $1 has a "=", we want the exact match + if [ "$_o" = "$1" ]; then + _val="1"; + unset _doecho + fi + continue + fi + + if [ "${_o#*=}" = "$_o" ]; then + # if cmdline argument has no "=", we assume "=1" + _val="1"; + unset _doecho + continue + fi + + _val=${_o#*=}; + _doecho=1 fi - [ "${_o%%=*}" = "${1%=}" ] && _val=${_o#*=}; done if [ -n "$_val" ]; then - echo $_val; + [ "x$_doecho" != "x" ] && echo $_val; return 0; fi return 1; @@ -67,13 +84,13 @@ getarg() { set +x while [ $# -gt 0 ]; do case $1 in - -y) if _dogetarg $2; then + -y) if _dogetarg $2 >/dev/null; then echo 1 [ "$RD_DEBUG" = "yes" ] && set -x return 0 fi shift 2;; - -n) if _dogetarg $2; then + -n) if _dogetarg $2 >/dev/null; then echo 0; [ "$RD_DEBUG" = "yes" ] && set -x return 1