1 (* Generic lens for shell-script config files like the ones found *)
2 (* in /etc/sysconfig, where a string needs to be split into *)
4 module Shellvars_list =
9 let key_re = /[A-Za-z0-9_]+/
10 let eq = Util.del_str "="
11 let comment = Util.comment
12 let empty = Util.empty
13 let indent = Util.indent
15 let sqword = /[^ '\t\n]+/
16 let dqword = /([^ "\\\t\n]|\\\\.)+/
17 let uqword = /([^ "'\\\t\n]|\\\\.)+/
19 (* lists values of the form ... val1 val2 val3 ... *)
20 let list(word:regexp) =
21 let list_value = store word in
23 [ label "value" . list_value ] .
24 [ del /[ \t\n]+/ " " . label "value" . list_value ]* . indent
27 (* handle single quoted lists *)
28 let squote_arr = [ label "quote" . store /'/ ] . (list sqword)? . del /'/ "'"
30 (* similarly handle double qouted lists *)
31 let dquote_arr = [ label "quote" . store /"/ ] . (list dqword)? . del /"/ "\""
33 (* handle unquoted single value *)
34 let unquot_val = [ label "quote" . store "" ] . [label "value" . store uqword+]?
37 (* lens for key value pairs *)
38 let kv = [ key key_re . eq . ( squote_arr | dquote_arr | unquot_val ) . eol ]
40 let lns = ( comment | empty | kv )*
42 let sc_incl (n:string) = (incl ("/etc/sysconfig/" . n))
43 let filter_sysconfig =
44 sc_incl "bootloader" .
47 let filter = filter_sysconfig
50 let xfm = transform lns filter
52 (* Local Variables: *)