grubby-bls: always escape the delimiter character used in sed commands

The forward slash character is used as the delimiter for sed substitutions
so this is escaped before calling sed.

But this was only done before removing parameters from the kernel command
and not when adding it. Use it for all the cases when the parameters are
replaced in the update_args() function.

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
This commit is contained in:
Javier Martinez Canillas 2020-05-04 14:57:52 +02:00
parent 1621d288b6
commit b1eee22db8
No known key found for this signature in database
GPG Key ID: C751E590D63F3D69
1 changed files with 2 additions and 1 deletions

View File

@ -459,8 +459,8 @@ update_args() {
local add_args=($1) && shift
for arg in ${remove_args[*]}; do
arg="$(echo $arg | sed -e 's/\//\\\//g')"
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")"
@ -469,6 +469,7 @@ update_args() {
for arg in ${add_args[*]}; do
arg="${arg%%=*}"
arg="$(echo $arg | sed -e 's/\//\\\//g')"
args="$(echo $args | sed -E "s/(^|[[:space:]])$arg(([[:space:]]|$)|([=][^ ]*([$]*)))/ /g")"
done