Hi, While I was playing with parsestringarray and file edition, I came across an odd behaviour in file editing, where line were not added in the expected order. I was expecting to have this ocntent for the file /tmp/keysfile : key3=value3 key2=value2 key1=value1
but I got : key3=value3 key2=value2 key4=value4 key1=value1 with the following promise. What am I missing ? Tested with Cfengine 3.1.5b3 and 3.1.4 with readstringarray Regards ---- Promise file body common control { bundlesequence => { "parse_string" }; } bundle agent parse_string { vars: "table" string => "key1:value1 key2:value2 key3:value3 key4:value4", comment => "Define my key:values"; "dim" int => parsestringarray( "keys", "$(table)", "\s*#[^\n]*", ":", "1000", "200000" ), comment => "Extracting the data from the variable"; files: "/tmp/keysfile" create => "true", edit_line => add_key_value("parse_string.keys"), comment => "Editing the file"; } # Edit the file, adding the key=value from the parsed variable # [0] : key # [1] : value bundle edit_line add_key_value(my_array) { vars: "index" slist => getindices("$(my_array)"); insert_lines: "$($(my_array)[$(index)][0])=$($(my_array)[$(index)][1])"; } -- Nicolas CHARLES Normation SAS - http://www.normation.com 44 rue Cauchy – 94110 Arcueil, FRANCE Standard +33 (0)1 83 62 26 96 Tél direct +33 (0)1 83 62 57 47 _______________________________________________ Help-cfengine mailing list Help-cfengine@cfengine.org https://cfengine.org/mailman/listinfo/help-cfengine