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

readstringarrayidx returns scrambled array and ignores duplicate lines

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Done
    • Priority: Blocker
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.6.2
    • Component/s: Built-in functions
    • Labels:
      None

      Description

      In 3.6.1 readstringarrayidx creates a scrambled array.

      <pre>
      R: CFEngine version: 3.6.1
      R: Number of elements: 20
      R: 14, other field 14
      R: 16, other field 16
      R: 6, other field 6
      R: 12, other field 12
      R: 15, other field 15
      R: 13, other field 13
      R: 1, other field 1
      R: 20, other field 20
      R: 9, other field 9
      R: 5, other field 5
      R: 8, other field 8
      R: 17, other field 17
      R: 7, other field 7
      R: 4, other field 4
      R: 18, other field 18
      R: 11, other field 11
      R: 2, other field 2
      R: 10, other field 10
      R: 19, other field 19
      R: 3, other field 3

      2014-07-30T19:05:33-0400 notice: R: CFEngine version: 3.5.2
      2014-07-30T19:05:33-0400 notice: R: Number of elements: 20
      2014-07-30T19:05:33-0400 notice: R: 1, other field 1
      2014-07-30T19:05:33-0400 notice: R: 2, other field 2
      2014-07-30T19:05:33-0400 notice: R: 3, other field 3
      2014-07-30T19:05:33-0400 notice: R: 4, other field 4
      2014-07-30T19:05:33-0400 notice: R: 5, other field 5
      2014-07-30T19:05:33-0400 notice: R: 6, other field 6
      2014-07-30T19:05:33-0400 notice: R: 7, other field 7
      2014-07-30T19:05:33-0400 notice: R: 8, other field 8
      2014-07-30T19:05:33-0400 notice: R: 9, other field 9
      2014-07-30T19:05:33-0400 notice: R: 10, other field 10
      2014-07-30T19:05:33-0400 notice: R: 11, other field 11
      2014-07-30T19:05:33-0400 notice: R: 12, other field 12
      2014-07-30T19:05:33-0400 notice: R: 13, other field 13
      2014-07-30T19:05:33-0400 notice: R: 14, other field 14
      2014-07-30T19:05:33-0400 notice: R: 15, other field 15
      2014-07-30T19:05:33-0400 notice: R: 16, other field 16
      2014-07-30T19:05:33-0400 notice: R: 17, other field 17
      2014-07-30T19:05:33-0400 notice: R: 18, other field 18
      2014-07-30T19:05:33-0400 notice: R: 19, other field 19
      2014-07-30T19:05:33-0400 notice: R: 20, other field 20

      body common control
      {
      bundlesequence =>

      { "main", }

      ;
      }

      bundle agent main
      {
      methods:
      "any" usebundle => init;
      "any" usebundle => test;
      }

      bundle agent init
      {
      vars:
      "file" string => "
      1 ;; other field 1
      2 ;; other field 2
      3 ;; other field 3
      4 ;; other field 4
      5 ;; other field 5
      6 ;; other field 6
      7 ;; other field 7
      8 ;; other field 8
      9 ;; other field 9
      10 ;; other field 10
      11 ;; other field 11
      12 ;; other field 12
      13 ;; other field 13
      14 ;; other field 14
      15 ;; other field 15
      16 ;; other field 16
      17 ;; other field 17
      18 ;; other field 18
      19 ;; other field 19
      20 ;; other field 20
      ";

      files:
      "${sys.workdir}/inputs/array.txt"
      create => 'true',
      edit_defaults => empty,
      edit_line => insert_lines( ${file} );
      }

      bundle agent test
      {
      vars:
      "num" int => readstringarrayidx(
      "mylines",
      "${sys.workdir}/inputs/array.txt",
      "\s*#[^\n]*",
      "\s*;;\s*",
      50,
      9999
      );

      "i" ilist =>

      { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 }

      ;

      reports:
      "CFEngine version: ${sys.cf_version}";
      "Number of elements: ${num}";
      "${mylines[${i}][0]}, ${mylines[${i}][1]}";
      }

      bundle edit_line insert_lines(lines)
      {
      insert_lines:
      }

      body edit_defaults empty
      {
      empty_file_before_editing => "true";
      edit_backup => "false";
      }
      </pre>

        Attachments

          Activity

            People

            • Assignee:
              a10050 Edward Welbourne (Inactive)
              Reporter:
              neilhwatson Neil Watson
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Summary Panel