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

using format() on lists produces --empty-list--

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: Low
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Built-in functions
    • Labels:
      None

      Description

      When combining usage of the format("%S, mylist) function with difference(), it produces a string -empty-list- that is likely a internal placeholder.
      The list does not show this placeholder when iterated over nor when using the join() function.

      Manual test case attached and below, with output.

      <pre>
      body common control
      {
      bundlesequence =>

      { "test" }

      ;
      }

      bundle agent test
      {
      vars:
      "a" slist =>

      { "test", ".", "item", ".." };
      "b" slist => { ".", ".." };

      "diff_between_a_and_b" slist => difference(a, b);

      "a_str" string => format("%S", a);
      "b_str" string => format("%S", b);
      "diff_str_format" string => format("%S", diff_between_a_and_b);
      "diff_str_join" string => join( ",", diff_between_a_and_b);

      reports:
      agent::
      "a: $(a_str)";
      "b: $(b_str)";
      "diff from format: $(diff_str_format)";
      "diff from join: $(diff_str_join)";
      "diff item: $(diff_between_a_and_b)";
      }
      </pre>


      <pre>
      [root@node001 tmp]# cf-agent -K test.cf
      R: a: { "test", ".", "item", ".." }

      R: b:

      { ".", ".." }

      R: diff from format:

      { --empty-list--, "test", "item" }

      R: diff from join: test,item
      R: diff item: test
      R: diff item: item
      </pre>

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              a10003 Eystein Maloy Stenberg
              Reporter:
              a10003 Eystein Maloy Stenberg
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated: