Browse Source

dracut-lib.sh: fixed getargs()

if $1 has a "=<value>", we want the exact match
if cmdline argument has no "=<value>", we assume "=1"
master
Harald Hoyer 14 years ago
parent
commit
9e7f495589
  1. 31
      modules.d/99base/dracut-lib.sh

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

@ -45,19 +45,36 @@ _getcmdline() { @@ -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 "=<value>", 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 "=<value>", 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() { @@ -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

Loading…
Cancel
Save