[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[augeas-devel] [PATCH] shellvars.aug



Updated shellvars to provide a simple way of altering commented settings and making them available, for example, in /etc/sysconfig/nfs by default "MOUNTD_PORT" is commented out. With this patch you can do something like :

augtool> rm /files/etc/sysconfig/nfs/MOUNTD_PORT/commented
augtool> set /files/etc/sysconfig/nfs/MOUNTD_PORT 543543

Making the settings commented out again is just as simple

augtool> clear /files/etc/sysconfig/nfs/MOUNTD_PORT/commented

Thanks

-- 
        __          __                
.-----.|  |_.-----.|  |--.-----.-----.
|__ --||   _|  _  ||    <|  -__|__ --|
|_____||____|_____||__|__|_____|_____|
 .----------------------------------.
(   ajs redhat com || 919.754.4187   )
 `----------------------------------'

--- shellvars.aug.stokes	2010-01-14 13:56:25.000000000 -0500
+++ shellvars.aug	2010-01-18 18:09:04.147580771 -0500
@@ -5,10 +5,13 @@
 
   let eol = Util.eol
 
-  let key_re = /[A-Za-z0-9_]+(\[[0-9]+\])?/ - "unset" - "export"
-  let eq = Util.del_str "="
-  let comment = Util.comment
+  let key_re  = /[A-Za-z0-9_]+(\[[0-9]+\])?/ - "unset" - "export"
+  let eq      = Util.del_str "="
   let empty   = Util.empty
+   let comment =
+      let simple_re =/((unset|export)[ \t]+)?[A-Za-z0-9_]+(\[[0-9]+\])?/ in
+      let line_re = /([^ \t\n].*[^ \t\n]|[^ \t\n])/ - /[ \t]*/ . simple_re . /=.*/ in
+      [ label "#comment" . del /#[ \t]*/ "# " . store line_re . del /\n/ "\n" ]
 
   let char  = /[^() '"\t\n]|\\\\"/
   let dquot = /"([^"\\\n]|\\\\.)*"/                    (* " Emacs, relax *)
@@ -32,7 +35,10 @@
       store (char* | dquot | squot | bquot | empty_array)
 
   let export = [ key "export" . Util.del_ws_spc ]
-  let kv = [ export? . key key_re . eq . (simple_value | array) . eol ]
+  let marker = [ del /#[ \t]*/ "# " . label "commented" ]
+  let kv = 
+      [ marker? . export? . key key_re . eq . (simple_value | array) . eol ]
+
 
   let unset = [ key "unset" . Util.del_ws_spc . store key_re . eol ]
 
@@ -105,3 +111,4 @@
 (* Local Variables: *)
 (* mode: caml       *)
 (* End:             *)
+

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]