Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion lib/files.cf
Original file line number Diff line number Diff line change
Expand Up @@ -1071,11 +1071,38 @@ bundle edit_line converge(marker, lines)
"regex" string => escape($(marker));

delete_lines:
"$(regex)" comment => "Delete lines matching the marker";
".*$(regex).*" comment => "Delete lines matching the marker";
insert_lines:
"$(lines)" comment => "Insert the given lines";
}

bundle edit_line converge_prepend(marker, lines)
# @brief Converge `lines` marked with `marker` to start of content.
#
# Any content marked with `marker` is removed, then `lines` are
# inserted at *start* of content. Every `line` should contain `marker`.
#
# This is helpful for files where order matters, like `pam.d/common-auth`,
# and you want the content at the top. If you want to maintain the order
# of multiple lines, pass one item with a newline in it like this:
# ```
# "" usebundle => converge_prepend("covfefe", "first line of covfefe
# second line of covfefe");
# ```
#
# @param marker The marker (not a regular expression; will be escaped)
# @param lines The lines to insert; all must contain `marker`
{
Comment thread
nickanderson marked this conversation as resolved.
vars:
"regex" string => escape($(marker));

delete_lines:
".*$(regex).*" comment => "Delete lines matching the marker";
insert_lines:
"$(lines)" location => start, comment => "Insert the given lines";
}


bundle edit_line fstab_option_editor(method, mount, option)
# @brief Add or remove `/etc/fstab` options for a mount
#
Expand Down