[augeas-devel] [PATCH 3/6] Grub: parse individual arguments for serial command

David Lutterkort lutter at redhat.com
Thu Apr 9 23:17:06 UTC 2009


---
 lenses/grub.aug            |   10 ++++++++--
 lenses/tests/test_grub.aug |    9 +++++++++
 2 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/lenses/grub.aug b/lenses/grub.aug
index 8015a31..9faabf4 100644
--- a/lenses/grub.aug
+++ b/lenses/grub.aug
@@ -12,7 +12,8 @@ module Grub =
     let opt_ws = Util.del_opt_ws ""
     let dels (s:string) = Util.del_str s
     let eq = dels "="
-    let switch (n:string) = dels ("--" . n) . label n
+    let switch (n:regexp) = dels "--" . key n
+    let switch_arg (n:regexp) = switch n . eq . store Rx.no_spaces
     let value_sep (dflt:string) = del /[ \t]*[ \t=][ \t]*/ dflt
 
     let command (kw:string) (indent:string) =
@@ -44,12 +45,17 @@ module Grub =
         (spc . [ label "highlight" . color_spec ])? .
         eol ]
 
+    let serial =
+      [ command "serial" "" .
+        [ spc . switch_arg /unit|port|speed|word|parity|stop|device/ ]* .
+        eol ]
+
     let menu_setting = kw_menu_arg "default"
                      | kw_menu_arg "fallback"
                      | kw_pres "hiddenmenu"
                      | kw_menu_arg "timeout"
                      | kw_menu_arg "splashimage"
-                     | kw_menu_arg "serial"
+                     | serial
                      | kw_menu_arg "terminal"
                      | password_arg
                      | color
diff --git a/lenses/tests/test_grub.aug b/lenses/tests/test_grub.aug
index e104f35..7f26035 100644
--- a/lenses/tests/test_grub.aug
+++ b/lenses/tests/test_grub.aug
@@ -114,6 +114,15 @@ initrd\t\t/boot/initrd.img-2.6.18-6-vserver-686
       { "initrd" = "/boot/initrd.img-2.6.18-6-vserver-686" }
       { "savedefault" } }
 
+  test Grub.lns get
+      "serial --unit=0 --speed=9600 --word=8 --parity=no --stop=1\n"
+    =
+    { "serial"
+        { "unit" = "0" }
+        { "speed" = "9600" }
+        { "word" = "8" }
+        { "parity" = "no" }
+        { "stop" = "1" } }
 
 (* Local Variables: *)
 (* mode: caml       *)
-- 
1.6.0.6




More information about the augeas-devel mailing list