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 <javierm@redhat.com>
This commit is contained in:
Javier Martinez Canillas 2018-11-22 20:35:13 +01:00
parent d1dd184403
commit 4b1d63cacd
No known key found for this signature in database
GPG Key ID: C751E590D63F3D69
1 changed files with 12 additions and 18 deletions

View File

@ -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}