[augeas-devel] [Interfaces] Draft lense

David Lutterkort lutter at redhat.com
Mon Aug 25 21:41:24 UTC 2008


On Wed, 2008-08-20 at 20:58 +0200, Free Ekanayaka wrote:
> Hi Raphaël,
> 
> |--==> Raphaël Pinson writes:
> 
>   >>it would generate a tree like:
>   >>
>   >>{ "auto"
>   >>{ "1" = "lo" }
>   >>{ "2" = "eth0" } }
>   >>{ "auto"
>   >>{ "1" = "eth1" } }
>   >>
>   >>which is closer to the actual configuration file, but probably less
>   >>parsable than:
>   >>
>   >>{ "auto" = "lo" }
>   >>{ "auto" = "eth0" }
>   >>{ "auto" = "eth1" }
>   >>
> 
>   RP> If I'm not wrong, this tree would pose a problem on put, because it's not
>   RP> reversible. From looking at the tree, you can't tell how to represent it
>   RP> back in the file, so there will be a conflict imo.
> 
> Yes, I guessed something like that, but I also though that the engine
> could remember the original string. Not a big deal though. I've now
> implemented the auto stanza as seq, pretty like sshd.aug.

The issue is not with remembering pieces with the original string - it's
when you create a brandnew tree. Imaging you start with an empty file,
and you add nodes to the tree so that you havea tree

        { "auto" = "lo" }
        { "auto" = "eth0" }
        
When that tree is put back into the file, should that become one line
'auto lo eth0' or two lines 'auto lo\nauto eth0' ?

One way to disambiguate that is to use the structure that Raphael
mentioned above, i.e.
        { "auto" { "1" = "lo" } { "2" = "eth0" } }
if you want one line and 
     { "auto" { "1" = "lo" } } { "auto" { "2" = "eth0" } }
if you want two lines.

David





More information about the augeas-devel mailing list