dracut/0012-dracut-lib.sh-fixed-getargs.patch

74 lines
2.2 KiB
Diff
Raw Normal View History

From 9e7f4955895c1064e3bdd03f5f781efc9b98d5d6 Mon Sep 17 00:00:00 2001
From: Harald Hoyer <harald@redhat.com>
Date: Wed, 20 Jul 2011 21:12:17 +0200
Subject: [PATCH] dracut-lib.sh: fixed getargs()
if $1 has a "=<value>", we want the exact match
if cmdline argument has no "=<value>", we assume "=1"
---
modules.d/99base/dracut-lib.sh | 31 ++++++++++++++++++++++++-------
1 files changed, 24 insertions(+), 7 deletions(-)
diff --git a/modules.d/99base/dracut-lib.sh b/modules.d/99base/dracut-lib.sh
index 10025bd..c2202f1 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 "=<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() {
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