grubby-bls: escape delimiter character before replacing the options field

The ! character was used as the delimiter, but this doesn't work when the
param uses this character, for example "memmap=1G!1G".

Resolves: rhbz#1640017

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
This commit is contained in:
Javier Martinez Canillas 2018-10-17 20:36:08 +02:00
parent 84881fb396
commit 7d53b5e0a6
No known key found for this signature in database
GPG Key ID: C751E590D63F3D69

View File

@ -68,7 +68,8 @@ set_bls_value() {
local key="$1" && shift
local value="$1" && shift
sed -i -e "s!^${key}.*!${key} ${value}!" "${bls}"
value=$(echo $value | sed -e 's/\//\\\//g')
sed -i -e "s/^${key}.*/${key} ${value}/" "${bls}"
}
append_bls_value() {
@ -343,7 +344,8 @@ update_args() {
local add_args=($1) && shift
for arg in ${remove_args[*]}; do
args="$(echo $args | sed -e "s!$arg[^ ]*!!")"
arg=$(echo $arg | sed -e 's/\//\\\//g')
args="$(echo $args | sed -e "s/$arg[^ ]*//")"
done
for arg in ${add_args[*]}; do
@ -352,7 +354,8 @@ update_args() {
key=${arg%%=$value}
exist=$(echo $args | grep "${key}=")
if [[ -n $exist ]]; then
args="$(echo $args | sed -e "s!$key=[^ ]*!$key=$value!")"
value=$(echo $value | sed -e 's/\//\\\//g')
args="$(echo $args | sed -e "s/$key=[^ ]*/$key=$value/")"
else
args="$args $key=$value"
fi