Bump to 1.14.1
[platform/upstream/augeas.git] / lenses / shellvars_list.aug
1 (* Generic lens for shell-script config files like the ones found *)
2 (* in /etc/sysconfig, where a string needs to be split into       *)
3 (* single words.                                                  *)
4 module Shellvars_list =
5   autoload xfm
6
7   let eol = Util.eol
8
9   let key_re = /[A-Za-z0-9_]+/
10   let eq      = Util.del_str "="
11   let comment = Util.comment
12   let comment_or_eol = Util.comment_or_eol
13   let empty   = Util.empty
14   let indent  = Util.indent
15
16   let sqword = /[^ '\t\n]+/
17   let dqword = /([^ "\\\t\n]|\\\\.)+/
18   let uqword = /([^ `"'\\\t\n]|\\\\.)+/
19   let bqword = /`[^`\n]*`/
20   let space_or_nl = /[ \t\n]+/
21   let space_or_cl = space_or_nl | Rx.cl
22
23   (* lists values of the form ...  val1 val2 val3  ... *)
24   let list (word:regexp) (sep:regexp) =
25     let list_value = store word in
26       indent .
27       [ label "value" . list_value ] .
28       [ del sep " "  . label "value" . list_value ]* . indent
29
30
31   (* handle single quoted lists *)
32   let squote_arr = [ label "quote" . store /'/ ]
33                    . (list sqword space_or_nl)? . del /'/ "'"
34
35   (* similarly handle double quoted lists *)
36   let dquote_arr = [ label "quote" . store /"/ ]
37                    . (list dqword space_or_cl)? . del /"/ "\""
38
39   (* handle unquoted single value *)
40   let unquot_val = [ label "quote" . store "" ]
41                  . [ label "value"  . store (uqword+ | bqword)]?
42
43
44   (* lens for key value pairs *)
45   let kv = [ key key_re . eq .
46              ( (squote_arr | dquote_arr) . comment_or_eol
47              | unquot_val . eol )
48            ]
49
50   let lns = ( comment | empty | kv )*
51
52   let filter = incl "/etc/sysconfig/bootloader"
53              . incl "/etc/sysconfig/kernel"
54
55   let xfm = transform lns filter
56
57 (* Local Variables: *)
58 (* mode: caml       *)
59 (* End:             *)