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

regex_replace function doesn't respect it's "T" option

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Done
    • Priority: Medium
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.10.5, 3.12.1
    • Component/s: Documentation
    • Labels:
      None

      Description

      This isn't working:

      bundle agent main
      {
          vars:
              "filename" string => "hello_txt.txt";
              "replaced" string => regex_replace("$(filename)", ".txt", "", "T");
          # According to docs, this should replace the .txt part,
          # but it matches and replaces _txt instead
          reports:
              "Before: $(filename)";
              "After: $(replaced)";
      }
      

      https://docs.cfengine.com/docs/3.10/reference-functions-regex_replace.html

      When given the T option regex_replace should disable special characters and backreferences in the substitute string. The documentation incorrectly states that it shouldn't treat it's second option as a regex, but instead as a plain string.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                karlhto Karl Hole Totland
                Reporter:
                olehermanse Ole Herman Schumacher Elgesem
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Summary Panel