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

lsdir() doesn't run at all if regex doesn't match anything in the folder

    XMLWordPrintable

    Details

      Description

      Regarding https://groups.google.com/forum/#!topic/help-cfengine/6G1FNPih1Lo

      It seem that there is a confusing bug with lsdir. Here is a example : let's say we have this directory tree :

      test
      └── FR0000001-12345678.gz
      prod
      └── FR0000001-12345678.gz
      

      here is the code :

      body common control {
      bundlesequence  => { "readdirs" };
      }
      
      bundle agent readdirs {
      vars:
      "directories" slist => {"prod","test"};
      "files_regex_1_$(directories)" slist => lsdir("$(directories)",".*","false");
      "files_regex_2_$(directories)" slist => lsdir("$(directories)","FR.*\.gz","false");
      reports:
      any::
      "regex_1 : $(directories) - $(files_regex_1_$(directories))";
      "regex_2 : $(directories) - $(files_regex_2_$(directories))";
      }
      

      Normal output look like this :

      notice: R: regex_1 : prod - .
      notice: R: regex_1 : prod - ..
      notice: R: regex_1 : prod - FR0000001-12345678.gz
      notice: R: regex_1 : test - .
      notice: R: regex_1 : test - ..
      notice: R: regex_1 : test - FR0000001-12345678.gz
      notice: R: regex_2 : prod - FR0000001-12345678.gz
      notice: R: regex_2 : test - FR0000001-12345678.gz
      

      If i empty "prod" directory, output look like this :

      notice: R: regex_1 : prod - .
      notice: R: regex_1 : prod - ..
      notice: R: regex_1 : test - .
      notice: R: regex_1 : test - ..
      notice: R: regex_1 : test - FR0000001-12345678.gz
      

      As you can see, nothing seem to match regex_2. It seem that if one entry in the slist do not match file(s), lsdir do not return anything at all.

      Regards,
      Pascal Bonderff

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                a10042 Nick Anderson
                Reporter:
                pbonderff Pascal Bonderff
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Summary Panel