none

Table of Contents

Prototype: none(regex, list)

Return type: boolean

Description: Returns whether no element in list matches the regular expression regex.

This function can accept many types of data parameters.

Arguments:

  • regex: regular expression - Regular expression or string - in the range: .*
  • list: string - CFEngine variable identifier or inline JSON - in the range: .*

The regular expression is unanchored.

Example:

body common control
{
      bundlesequence => { "example" };
}

bundle agent example
{
  classes:
      "none11" expression => none("jebadiah", test1);
      "none12" expression => none("2", test1);
      "none21" expression => none("jebadiah", test2);
      "none22" expression => none("2", test2);

  vars:
      "test1" slist => {
                        1,2,3,
                        "one", "two", "three",
                        "long string",
                        "four", "fix", "six",
                        "one", "two", "three",
      };


      "test2" data => parsejson('[1,2,3,
                        "one", "two", "three",
                        "long string",
                        "four", "fix", "six",
                        "one", "two", "three",]');

  reports:
      "The test1 list is $(test1)";
    none11::
      "none() test1 1 passed";
    !none11::
      "none() test1 1 failed";
    none12::
      "none() test1 2 failed";
    !none12::
      "none() test1 2 passed";

      "The test2 list is $(test2)";
    none21::
      "none() test2 1 passed";
    !none21::
      "none() test2 1 failed";
    none22::
      "none() test2 2 failed";
    !none22::
      "none() test2 2 passed";
}

Output:

R: The test1 list is 1
R: The test1 list is 2
R: The test1 list is 3
R: The test1 list is one
R: The test1 list is two
R: The test1 list is three
R: The test1 list is long string
R: The test1 list is four
R: The test1 list is fix
R: The test1 list is six
R: none() test1 1 passed
R: none() test1 2 passed
R: The test2 list is 1
R: The test2 list is 2
R: The test2 list is 3
R: The test2 list is one
R: The test2 list is two
R: The test2 list is three
R: The test2 list is long string
R: The test2 list is four
R: The test2 list is fix
R: The test2 list is six
R: none() test2 1 passed
R: none() test2 2 passed

History: The collecting function behavior was added in 3.9.

See also: About collecting functions, filter(), every(), and some().