Skip to content

Commit

Permalink
Improve regular expressions
Browse files Browse the repository at this point in the history
This change will ensure that the first `sed` command that removes the
`kargs` key completely will also remove the following
`match-architectures` key if the key exists. Also, the second `sed`
command that just removes an item from the list if the list contains
multiple items has been adjusted to correctly remove commans between
the items.

Credit to Matus Marhefka 👍
  • Loading branch information
jan-cerny committed Dec 12, 2024
1 parent 2ce53c4 commit 32e5fdb
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
Product-specific categorization should be synced across all template content types
-#}}
if {{{ bash_bootc_build() }}} ; then
sed -i -E "/kargs\s*=\s*\[\s*\"{{{ ARG_NAME }}}=[^\"]*\"\s*]/d" "$KARGS_DIR/*.toml"
sed -i -E "s/^(\s*kargs\s*=\s*\[.*)\"{{{ ARG_NAME }}}=[^\"]*\"(.*]\s*)/\1\2/" "$KARGS_DIR/*.toml"
sed -i -E "/kargs\s*=\s*\[\s*\"{{{ ARG_NAME }}}=[^\"]*\"\s*]/{:a;N;/^\n$/ba;N;/match-architectures.*/d;}" "$KARGS_DIR/*.toml"
sed -i -E -e "s/^(\s*kargs\s*=\s*\[.*)\"{{{ ARG_NAME }}}=[^\"]*\"[,[:space:]]*(.*]\s*)/\1\2/" -e "s/^(\s*kargs.*),\s*\]$/\1\]/" "$KARGS_DIR/*.toml"
else
{{{ grub2_bootloader_argument_absent_remediation(ARG_NAME) }}}
fi

0 comments on commit 32e5fdb

Please sign in to comment.