From 80d3d5b865e68d18f6c0d49cf04f1b341d9be6fa Mon Sep 17 00:00:00 2001 From: Nick Anderson Date: Tue, 27 Oct 2026 17:22:27 -0500 Subject: [PATCH] Updated plucked.sub.cf from masterfiles Ticket: CFE-3898 Changelog: None Signed-off-by: Nick Anderson --- tests/acceptance/plucked.sub.cf | 58 +++++++++++++++++++++++++-------- 1 file changed, 45 insertions(+), 13 deletions(-) diff --git a/tests/acceptance/plucked.sub.cf b/tests/acceptance/plucked.sub.cf index ef7bda18137..6b6c3eceecf 100644 --- a/tests/acceptance/plucked.sub.cf +++ b/tests/acceptance/plucked.sub.cf @@ -63,9 +63,9 @@ body contain in_dir_shell(dir) # ``` { chdir => "$(dir)"; - useshell => "true"; # canonical "useshell" but this is backwards-compatible + useshell => "true"; } body contain in_shell @@ -79,9 +79,8 @@ body contain in_shell # contain => in_shell; # ``` { - useshell => "true"; - # canonical "useshell" but this is backwards-compatible + useshell => "true"; } body contain in_shell_bg @@ -90,9 +89,8 @@ body contain in_shell_bg # parser strictness enhancements. Backgrounding is handeled by the body action # background attribute. { - useshell => "true"; - # canonical "useshell" but this is backwards-compatible + useshell => "true"; } body contain in_shell_and_silent @@ -107,9 +105,8 @@ body contain in_shell_and_silent # comment => "Silently run command in shell"; # ``` { - useshell => "true"; - # canonical "useshell" but this is backwards-compatible + useshell => "true"; no_output => "true"; } @@ -126,9 +123,8 @@ body contain in_dir_shell_and_silent(dir) # comment => "Silently run command in shell"; # ``` { - useshell => "true"; - # canonical "useshell" but this is backwards-compatible + useshell => "true"; no_output => "true"; chdir => "$(dir)"; } @@ -752,10 +748,18 @@ bundle edit_line manage_variable_values_ini(tab, sectionName) { vars: "index" slist => getindices("$(tab)[$(sectionName)]"); + "_escaped_section" string => escape("$(sectionName)"); + + classes: + "section_$(sectionName)_exists" + expression => regline("^\[$(_escaped_section)\]", "$(edit.filename)"), + if => fileexists("$(edit.filename)"), + comment => "Check if the section header already exists in the file"; delete_lines: ".*" select_region => INI_section(escape("$(sectionName)")), + if => canonify("section_$(sectionName)_exists"), comment => "Remove all entries in the region so there are no extra entries"; insert_lines: @@ -764,7 +768,12 @@ bundle edit_line manage_variable_values_ini(tab, sectionName) comment => "Insert lines"; "$(index)=$($(tab)[$(sectionName)][$(index)])" - select_region => INI_section(escape("$(sectionName)")); + select_region => INI_section(escape("$(sectionName)")), + if => canonify("section_$(sectionName)_exists"); + + "$(index)=$($(tab)[$(sectionName)][$(index)])" + location => after("^\[$(_escaped_section)\]"), + if => not(canonify("section_$(sectionName)_exists")); } bundle edit_line set_variable_values_ini(tab, sectionName) @@ -786,18 +795,26 @@ bundle edit_line set_variable_values_ini(tab, sectionName) # Be careful if the index string contains funny chars "cindex[$(index)]" string => canonify("$(index)"); + "_escaped_section" string => escape("$(sectionName)"); classes: "edit_$(cindex[$(index)])" not => strcmp("$($(tab)[$(sectionName)][$(index)])", "dontchange"), comment => "Create conditions to make changes"; + "section_$(sectionName)_exists" + expression => regline("^\[$(_escaped_section)\]", "$(edit.filename)"), + if => fileexists("$(edit.filename)"), + comment => "Check if the section header already exists in the file"; + field_edits: # If the line is there, but commented out, first uncomment it "#+\s*$(index)\s*=.*" select_region => INI_section(escape("$(sectionName)")), edit_field => col("\s*=\s*", "1", "$(index)", "set"), - if => "edit_$(cindex[$(index)])"; + if => and( + "edit_$(cindex[$(index)])", canonify("section_$(sectionName)_exists") + ); # match a line starting like the key something "\s*$(index)\s*=.*" @@ -808,7 +825,9 @@ bundle edit_line set_variable_values_ini(tab, sectionName) classes => results( "bundle", "set_variable_values_ini_not_$(cindex[$(index)])" ), - if => "edit_$(cindex[$(index)])"; + if => and( + "edit_$(cindex[$(index)])", canonify("section_$(sectionName)_exists") + ); insert_lines: "[$(sectionName)]" @@ -817,7 +836,20 @@ bundle edit_line set_variable_values_ini(tab, sectionName) "$(index)=$($(tab)[$(sectionName)][$(index)])" select_region => INI_section(escape("$(sectionName)")), - if => "!(set_variable_values_ini_not_$(cindex[$(index)])_kept|set_variable_values_ini_not_$(cindex[$(index)])_repaired).edit_$(cindex[$(index)])"; + if => and( + "!(set_variable_values_ini_not_$(cindex[$(index)])_kept|set_variable_values_ini_not_$(cindex[$(index)])_repaired)", + "edit_$(cindex[$(index)])", + canonify("section_$(sectionName)_exists") + ), + handle => "insert_key_in_existing_section_$(sectionName)_$(cindex[$(index)])"; + + "$(index)=$($(tab)[$(sectionName)][$(index)])" + location => after("^\[$(_escaped_section)\]"), + if => and( + "edit_$(cindex[$(index)])", + not(canonify("section_$(sectionName)_exists")) + ), + handle => "insert_key_in_new_section_$(sectionName)_$(cindex[$(index)])"; } bundle edit_line insert_ini_section(name, config)