#######################################################
#
# Replace a pattern and use match.0
#
#######################################################

body common control
{
      inputs => { "../../default.cf.sub" };
      bundlesequence  => { default("$(this.promise_filename)") };
      version => "1.0";
}

#######################################################

bundle agent init
{
  vars:
      "states" slist => { "actual", "expected" };

      "actual" string =>
      "BEGIN
kernel /vmlinuz-2.6.18-348.el5 ro noapic nolapic apci=off time process_timing=everything root=LABEL=/foo
kernel /vmlinuz-2.6.18-348.el5 ro root=LABEL=/1
END";

      "expected" string =>
      "BEGIN
kernel /vmlinuz-2.6.18-348.el5 ro noapic nolapic apci=off time process_timing=everything root=LABEL=/foo
kernel /vmlinuz-2.6.18-348.el5 ro root=LABEL=/1
END";

  files:
      "$(G.testfile).$(states)"
      create => "true",
      edit_line => init_insert("$(init.$(states))"),
      edit_defaults => init_empty;
}

bundle edit_line init_insert(str)
{
  insert_lines:
      "$(str)";
}

body edit_defaults init_empty
{
      empty_file_before_editing => "true";
}

######################################################
#
bundle agent test
{
  files:
      "$(G.testfile).actual"
      edit_line => test_replace("$(init.parameters)");
}

bundle edit_line test_replace(parameters)
{
  replace_patterns:

      # should not change anything
      "^.+$"
      replace_with => value("$(match.0)");
}

#######################################################

bundle agent check
{
  methods:
      "any" usebundle => dcs_check_diff("$(G.testfile).actual",
                                            "$(G.testfile).expected",
                                            "$(this.promise_filename)");
}
### PROJECT_ID: core
### CATEGORY_ID: 27
