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

filesexist does not accept arguments with hash '#" and other special characters

    XMLWordPrintable

    Details

    • Platform:
      Debian

      Description

      I need tested these files or directories:

       

      /opt/tomcat7/webapps/PortalUpdaterClient##*
      /opt/tomcat8/webapps/PortalUpdaterClient##*

      When using

      classes:
        "found" expression =>
          filesexist(findfiles("/opt/tomcat7/webapps/PortalUpdaterClient##*", "/opt/tomcat8/webapps/PortalUpdaterClient##*"))

      Then get:

      Argument template mismatch handling function filesexist( {"/opt/tomcat7/webapps/PortalUpdaterClient##v170804-1605","/opt/tomcat7/webapps/PortalUpdaterClient##v170804-1605.war","/opt/tomcat8/webapps/PortalUpdaterClient##v170804-1605","/opt/tomcat8/webapps/PortalUpdaterClient##v170804-1605.war"})
       arg[0] range @[(][a-zA-Z0-9_$(){}\[\].:]+[)] /opt/tomcat7/webapps/PortalUpdaterClient##v170804-1605
       error: Fatal CFEngine error: Bad arguments

      Workaround1: use filexists through slist variable.

        classes:
          # This should always be true.
          # We check that the files that we found exist.
      
          "found_expected_files_with_filesexist"
            expression => filesexist( findfiles( "$(G.testdir)/example##*") ),
            scope => "namespace";
      
          # Expecting to have classes:
          # found_example__4567
          # found_example__123
      
          "found_$(init.test_files)"
            expression => fileexists( $(init.test_files) ),
            scope => "namespace";
      

      Workaround2: Use variable to hold result from findfiles() and provide that variable as input to filesexist()

        vars:
            "found_files" slist => findfiles( "$(G.testdir)/example*");
      
        classes:
          # This should always be true.
          # We check that the files that we found exist.
      
          "found_expected_files_with_filesexist"
            expression => filesexist( "@(found_files)" ),
              scope => "namespace";
      

       

       

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                vpodzime Vratislav Podzimek
                Reporter:
                svamberg Michal Švamberg
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Summary Panel