Skip to content

Commit 0c5e1d5

Browse files
committed
Code rabbit fix
1 parent b5fa746 commit 0c5e1d5

1 file changed

Lines changed: 18 additions & 6 deletions

File tree

emhttp/plugins/dynamix/scripts/manage_boot_params.sh

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -273,21 +273,26 @@ parse_append_line() {
273273
# Matches from "label $label" to the next "label" or end of file
274274
# Normalize CRLF to LF for parsing (DOS-edited syslinux.cfg)
275275
tr -d '\r' < "$cfg_file" | awk -v label="$label" '
276-
BEGIN { label=tolower(label) }
276+
BEGIN {
277+
label=tolower(label)
278+
gsub(/^[[:space:]]+|[[:space:]]+$/, "", label)
279+
gsub(/[[:space:]]+/, " ", label)
280+
}
277281
{
278282
sub(/\r$/, "")
279283
}
280284
/^label[[:space:]]+/ {
281285
line=tolower($0)
282286
gsub(/^[[:space:]]+|[[:space:]]+$/, "", line)
283-
if (line == "label " label) {
287+
gsub(/[[:space:]]+/, " ", line)
288+
if (line ~ "^label[[:space:]]+" label "$") {
284289
in_section=1
285290
} else {
286291
in_section=0
287292
}
288293
}
289-
in_section && /^[[:space:]]+append[[:space:]]+/ {
290-
sub(/^[[:space:]]+append[[:space:]]+/, "")
294+
in_section && /^[[:space:]]*append([[:space:]]|$)/ {
295+
sub(/^[[:space:]]*append[[:space:]]+/, "")
291296
print
292297
exit
293298
}
@@ -830,14 +835,21 @@ update_syslinux_label_append() {
830835
local cfg_file="$3"
831836

832837
awk -v label="$target_label" -v append_args="$append_args" '
833-
/^[[:space:]]*label / {
838+
BEGIN {
839+
normalized_label = label
840+
gsub(/^[[:space:]]+|[[:space:]]+$/, "", normalized_label)
841+
gsub(/[[:space:]]+/, " ", normalized_label)
842+
}
843+
/^[[:space:]]*label[[:space:]]+/ {
834844
if (in_section && !replaced) {
835845
print section_indent "append " append_args
836846
}
837847
838848
current_label = $0
839849
sub(/^[[:space:]]*label[[:space:]]+/, "", current_label)
840-
in_section = (current_label == label)
850+
gsub(/^[[:space:]]+|[[:space:]]+$/, "", current_label)
851+
gsub(/[[:space:]]+/, " ", current_label)
852+
in_section = (current_label == normalized_label)
841853
replaced = 0
842854
section_indent = " "
843855
}

0 commit comments

Comments
 (0)