[augeas-devel] Using Shellvars for Gentoo's conf.d/net config

David Lutterkort lutter at redhat.com
Tue Feb 2 21:08:16 UTC 2010


On Tue, 2010-02-02 at 15:54 -0500, Doug Warner wrote:
> /etc/conf.d/net contains:
> config_eth0=( "null" )
> config_eth1=( "10.128.0.48/24" )
> routes_eth1=( "default via 10.128.0.254" )

The Shellvars lens currently doesn't allow spaces after the opening '('
and before the closing ')'. The patch below (which I just pushed) takes
care of that:

> From e5b36fcd2f8a54e68b607127de0b3e9716541ef2 Mon Sep 17 00:00:00 2001
From: David Lutterkort <lutter at redhat.com>
Date: Tue, 2 Feb 2010 13:03:37 -0800
Subject: [PATCH] Shellvars: allow spaces after/before opening/closing parens for array

Bug reported by Doug Warner
---
 lenses/shellvars.aug            |    4 ++--
 lenses/tests/test_shellvars.aug |    4 ++++
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/lenses/shellvars.aug b/lenses/shellvars.aug
index b407bac..59f4709 100644
--- a/lenses/shellvars.aug
+++ b/lenses/shellvars.aug
@@ -20,10 +20,10 @@ module Shellvars =
   (* treated as a simple value                                           *)
   let array =
     let array_value = store (char+ | dquot) in
-    del "(" "(" . counter "values" .
+    del /\([ \t]*/ "(" . counter "values" .
       [ seq "values" . array_value ] .
       [ del /[ \t\n]+/ " " . seq "values" . array_value ] *
-      . del ")" ")"
+      . del /[ \t]*\)/ ")"
 
   (* Treat an empty list () as a value '()'; that's not quite correct *)
   (* but fairly close.                                                *)
diff --git a/lenses/tests/test_shellvars.aug b/lenses/tests/test_shellvars.aug
index 94fb747..584fac6 100644
--- a/lenses/tests/test_shellvars.aug
+++ b/lenses/tests/test_shellvars.aug
@@ -106,6 +106,10 @@ unset ONBOOT
     { "2" = "v2" }
     { "3" = "v3" } }
 
+  (* Allow spaces after/before opening/closing parens for array *)
+  test Shellvars.lns get "config_eth1=( \"10.128.0.48/24\" )\n" =
+  { "config_eth1"  { "1" = "\"10.128.0.48/24\"" } }
+
 (* Local Variables: *)
 (* mode: caml       *)
 (* End:             *)
-- 
1.6.6






More information about the augeas-devel mailing list