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

ifelse should be actuated when more than 3 arguments are used with unresolved variables

    XMLWordPrintable

    Details

    • Type: Story
    • Status: Open
    • Priority: High
    • Resolution: Unresolved
    • Affects Version/s: 3.7.4, 3.12.2
    • Fix Version/s: None
    • Component/s: Built-in functions
    • Labels:
      None

      Description

      As stated in the documentation:

      Note: As a general rule function evaluation is skipped when undefined
      variables are used. However this function has special behavior when
      exactly three arguments are used, allowing it to be evaluated even if it
      contains undefined variables.
      

      with 3 it works with un-expanded variables, `version` is initialized:

      "version" string => ifelse(
         isvariable("sara_data.cfengine[version]"), "$(sara_data.cfengine[version])",
         ""
      );
      

      So that this does not work because the variable `$(sara_data.cfengine[version])` is un-expanded and `version` is not initailized:

      "version" string => ifelse(
         "CFENGINE_TEST_PACKAGE", "latest",
         isvariable("sara_data.cfengine[version]"), "$(sara_data.cfengine[version])",
         ""
      );
      

      But I test if the variable exists and if yes use it.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                bas Bas van der Vlies
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:

                  Summary Panel