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

List iteration in ifelse function only evaluates last item in list.

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Rejected
    • Priority: Low
    • Resolution: Done
    • Affects Version/s: 3.7.1
    • Fix Version/s: None
    • Component/s: Built-in functions
    • Labels:
      None
    • Environment:
      CentOS 6.6

      Description

      When using a ifelse with a list, the ifelse only evaluates the last item of the list.

      Example:

      Unable to find source-code formatter for language: cfengine. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
      bundle agent main {
        vars:
          "foobar_1" slist => {"bar1", "foo1"};
          "if_res1" string => ifelse("$(foobar_1)", "$(foobar_1)", "default");
          "var_res1" string => "default";
          "var_res1" string => "$(foobar_1)",
                         if => "$(foobar_1)";
      
          "foobar_2" slist => {"foo1", "bar1"};
          "if_res2" string => ifelse("$(foobar_2)", "$(foobar_2)", "default");
          "var_res2" string => "default";
          "var_res2" string => "$(foobar_2)",
                         if => "$(foobar_2)";
      
        classes:
          "foo1" expression => "any";
      
        reports:
          "if_res1 : $(if_res1) should be foo1";
          "var_res1 : $(var_res1) should be foo1";
      
          "if_res2 : $(if_res2) should be foo1";
          "var_res2 : $(var_res2) should be foo1";
      }
      
      
      
      # cf-agent -KIf ./test.cf
      R: if_res1 : foo1 should be foo1
      R: var_res1 : foo1 should be foo1
      R: if_res2 : default should be foo1
      R: var_res2 : foo1 should be foo1
      
      

        Attachments

          Activity

            People

            • Assignee:
              a10042 Nick Anderson
              Reporter:
              cffr Christoffer Frost
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Summary Panel