kdumpctl: fix a bug in remove_cmdline_param()

For the following scripts:
  cmdline="root=/dev/mapper/fedora-root rd.lvm.lv=fedora/root rw"
  remove_cmdline_param $cmdline "root"

  cmdline="root=nfs4:192.168.122.9:/ ip=ens3:dhcp rw"
  remove_cmdline_param $cmdline "root"

The current implementation will get the wrong results:
  "rd.lvm.lv=fedora/ rw"
  ":/ ip=ens3:dhcp rw"

After this patch we can get the correct results:
  "rd.lvm.lv=fedora/root rw"
  "ip=ens3:dhcp rw"

Signed-off-by: Xunlei Pang <xlpang@redhat.com>
Acked-by: Pratyush Anand <panand@redhat.com>
Acked-by:Dave Young <dyoung@redhat.com>
This commit is contained in:
Xunlei Pang 2017-04-05 19:34:11 +08:00 committed by Dave Young
parent 21dcf7e3b1
commit bf5b3da107
1 changed files with 3 additions and 2 deletions

View File

@ -68,8 +68,9 @@ remove_cmdline_param()
for arg in $@; do
cmdline=`echo $cmdline | \
sed -e "s/\b$arg=[^ ]*\b//g" \
-e "s/\b$arg\b//g" \
sed -e "s/\b$arg=[^ ]*//g" \
-e "s/^$arg\b//g" \
-e "s/[[:space:]]$arg\b//g" \
-e "s/\s\+/ /g"`
done
echo $cmdline