From 4b1d63cacdc07b6a8c7c3f65701e1cd7d7262252 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Thu, 22 Nov 2018 20:35:13 +0100 Subject: [PATCH] grubby-bls: allow to specify the same kernel param multiple times The kernel command line can contain parameters that are specified multiple times. This is supported by the old grubby tool but ins't supported by the grubby BLS wrapper. Allow the grubby wrapper to do the same. Resolves: rhbz#1652486 Signed-off-by: Javier Martinez Canillas --- grubby-bls | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/grubby-bls b/grubby-bls index e0614bd..c9bf226 100755 --- a/grubby-bls +++ b/grubby-bls @@ -421,27 +421,21 @@ update_args() { local add_args=($1) && shift for arg in ${remove_args[*]}; do - arg=$(echo $arg | sed -e 's/\//\\\//g') - args="$(echo $args | sed -e "s/$arg[^ ]*//")" + if [[ $arg = *"="* ]]; then + arg=$(echo $arg | sed -e 's/\//\\\//g') + args="$(echo $args | sed -E "s/(^|[[:space:]])$arg([[:space:]]|$)/ /")" + else + args="$(echo $args | sed -E "s/(^|[[:space:]])$arg(([[:space:]]|$)|([=][^ ]*([$]*)))/ /g")" + fi done for arg in ${add_args[*]}; do - if [[ $arg = *"="* ]]; then - value=${arg##*=} - key=${arg%%=$value} - exist=$(echo $args | grep "${key}=") - if [[ -n $exist ]]; then - value=$(echo $value | sed -e 's/\//\\\//g') - args="$(echo $args | sed -e "s/$key=[^ ]*/$key=$value/")" - else - args="$args $key=$value" - fi - else - exist=$(echo $args | grep $arg) - if ! [[ -n $exist ]]; then - args="$args $arg" - fi - fi + arg=${arg%=*} + args="$(echo $args | sed -E "s/(^|[[:space:]])$arg(([[:space:]]|$)|([=][^ ]*([$]*)))/ /g")" + done + + for arg in ${add_args[*]}; do + args="$args $arg" done echo ${args}