Use ! instead of , as sed delimiter in grubby-bls script

The script uses sed to modify the options field in the BLS entries, but it
is using a ',' character as the sed delimiter. It's total valid to have a
kernel command line parameter that contains that character, for example:

$ grubby --add-kernel=/boot/vmlinuz --args="console=ttyS0,115200n81" \
  --initrd=/boot/initrd.img --make-default --title=install
sed: -e expression #1, char 42: unknown option to `s'

Fix this by using a different delimiter that won't be present in a cmdline.

Resolves: rhbz#1634744

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
This commit is contained in:
Javier Martinez Canillas 2018-10-04 17:54:42 +02:00
parent f9880644e6
commit 28952a66c8
No known key found for this signature in database
GPG Key ID: C751E590D63F3D69

View File

@ -56,7 +56,7 @@ get_bls_value() {
local bls="$1" && shift
local key="$1" && shift
echo "$(grep "^${key}[ \t]" "${bls}" | sed -e "s,^${key}[ \t]*,,")"
echo "$(grep "^${key}[ \t]" "${bls}" | sed -e "s!^${key}[ \t]*!!")"
}
set_bls_value() {
@ -64,7 +64,7 @@ set_bls_value() {
local key="$1" && shift
local value="$1" && shift
sed -i -e "s,^${key}.*,${key} ${value}," "${bls}"
sed -i -e "s!^${key}.*!${key} ${value}!" "${bls}"
}
append_bls_value() {
@ -322,7 +322,7 @@ update_args() {
local add_args=($1) && shift
for arg in ${remove_args[*]}; do
args="$(echo $args | sed -e "s,$arg[^ ]*,,")"
args="$(echo $args | sed -e "s!$arg[^ ]*!!")"
done
for arg in ${add_args[*]}; do
@ -331,7 +331,7 @@ update_args() {
key=${arg%%=$value}
exist=$(echo $args | grep "${key}=")
if [[ -n $exist ]]; then
args="$(echo $args | sed -e "s,$key=[^ ]*,$key=$value,")"
args="$(echo $args | sed -e "s!$key=[^ ]*!$key=$value!")"
else
args="$args $key=$value"
fi