Uploaded image for project: 'CFEngine Community'
  1. CFEngine Community
  2. CFE-2263

select_end no longer matches EOF consistently

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Done
    • Priority: High
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.9.0, 3.10.0
    • Component/s: Promise type: files
    • Labels:
      None
    • Story Points:
      8
    • Platform:
      RHEL or CentOS

      Description

      delete_lines does not consider EOF as end of section, while insert_lines does consider EOF as end of section.

      Consider the following text file and policy.

      /tmp/f.ini

      [1]
      v1 = 1
      v2 = 2
      [2]
      v1 = 1
      v2 = 2
      

      /tmp/tx.cf

      bundle agent t { 
      vars: 
      "l" slist => { "1", "2" };
      
      files: 
      "/tmp/f.ini" 
      edit_line => e("\[$(l)\]"); 
      }
      
      bundle edit_line e(regex){ 
      delete_lines: 
      "v2 = 2" 
      select_region => r("$(regex)"); 
      }
      
      body select_region r(regex) { 
      select_start => "^$(regex)$"; 
      select_end => "\s*\[.*"; 
      }
      

      Expected result (3.6.2 and earlier versions produce this):

      # cf-agent -K -f /tmp/tx.cf -b t 
      # cat /tmp/f.ini 
      [1] 
      v1 = 1 
      [2] 
      v1 = 1
      

      Actual result (3.6.3 and later):

      # cf-agent -K -f /tmp/tx.cf -b t 
      # cat /tmp/f.ini 
      [1] 
      v1 = 1 
      [2] 
      v1 = 1 
      v2 = 2
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                a10053 Marcin Pasinski
                Reporter:
                a10003 Eystein Maloy Stenberg
              • Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Summary Panel