Files
home-assistant-addons/vhclient/rootfs/usr/bin/vh_editini.awk
Hans Karlinius 9a5858b3e9 test
2024-12-03 04:04:53 +01:00

45 lines
585 B
Awk
Executable File

#!/usr/bin/awk -f
BEGIN {
found_section = 0;
found_key = 0;
edited_row = 0;
}
$0 ~ "^" key "=" {
if (found_section) {
found_key = 1;
edited_row = 1;
if (value || value == 0) {
print key "=" value;
}
}
}
$0 ~ "^\\[" {
if (found_section && !found_key) {
found_key = 1;
if (value || value == 0) {
print key "=" value;
}
}
}
$0 ~ "^\\[" section "\\]" {
found_section = 1;
}
/.*/ {
if(!edited_row) {
print $0;
}
edited_row = 0;
}
END {
if (!found_section) {
print "[" section "]";
print key "=" value;
}
}