Skip to content

Instantly share code, notes, and snippets.

@raphink
Created April 7, 2014 09:46
Show Gist options
  • Save raphink/10017425 to your computer and use it in GitHub Desktop.
Save raphink/10017425 to your computer and use it in GitHub Desktop.
Support flags in simplevars
(*
Module: Simplevars
Parses simple key = value conffiles
Author: Raphael Pinson <[email protected]>
About: License
This file is licenced under the LGPL v2+, like the rest of Augeas.
About: Lens Usage
To be documented
About: Examples
The <Test_Simplevars> file contains various examples and tests.
*)
module Simplevars =
autoload xfm
(* Variable: to_comment_re
The regexp to match the value *)
let to_comment_re =
let to_comment_squote = /'[^\n']*'/
in let to_comment_dquote = /"[^\n"]*"/
in let to_comment_noquote = /[^\n \t'"#][^\n#]*[^\n \t#]|[^\n \t'"#]/
in to_comment_squote | to_comment_dquote | to_comment_noquote
(* View: entry *)
let entry = [ key Rx.word . del /[ \t]*=/ " ="
. (del Rx.opt_space " " . store to_comment_re)?
. (Util.eol|Util.comment_eol) ]
(* View: lns *)
let lns = (Util.empty | Util.comment | entry)*
(* Variable: filter *)
let filter = incl "/etc/kernel-img.conf"
. incl "/etc/kerneloops.conf"
. incl "/etc/wgetrc"
. incl "/etc/zabbix/*.conf"
. incl "/etc/audit/auditd.conf"
. incl "/etc/mixerctl.conf"
. incl "/etc/wsconsctlctl.conf"
. incl "/etc/selinux/semanage.conf"
let xfm = transform lns filter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment