[augeas-devel] Augeas to parse informational files from install CDs?

David Lutterkort lutter at redhat.com
Tue Feb 1 19:52:49 UTC 2011


On Fri, 2011-01-28 at 21:16 -0500, Owen Mann wrote:
> Okay, while working on this, I've found the following oddness:
> 
> let foo = [ key /A/ | key /B/ ]
> 
> ...yields:
> /usr/share/augeas/lenses/txtsetup.aug:19.0-.31:Failed to compile foo
> /usr/share/augeas/lenses/txtsetup.aug:19.12-.29:exception: overlapping lenses in tree union.put
>      Example matched by both:
>      First lens: /usr/share/augeas/lenses/txtsetup.aug:19.12-.19:
>      Second lens: /usr/share/augeas/lenses/txtsetup.aug:19.22-.29:
> 
> Notice "Example matched by both:" is null.
> 
> According to http://augeas.net/docs/lenses.html#lens-combinators (as I understand it), this should work.
> Is this a bug?

It's an unfortunate side-effect of how Augeas does its typechecking in
the tree -> string direction: for that direction it only looks at the
labels (and values) of tree nodes at one level. In particular, it does
not look at the (possible) labels of tree nodes that will be constructed
at the next level up in the tree.

The error you get is caused by the construct 'key /A/ | key /B/' - the
trees generated by both key lenses is the empty tree (a tree node isn't
constructed from the key node until you enclose the whole construct into
square brackets) And since both sides generate the empty tree, there is
an overlap as there's no way to determine which branch of the
alternation should be taken.

In reality of course, this typecheck error is spurious, since we can
tell from the construct '[ key /A/ | key /B/ ]' which branch to take
when confronted with a node { 'A' } or { 'B' }

One way to work around this is to put the branches into different
'[ ... ]', i.e. write
        [ key /A/ ] | [ key /B/ ]
        
I've been meaning to fix, or at least alleviate, the situation; but that
requires some hairy changes to the typechecker that I haven't had the
time to make.

David





More information about the augeas-devel mailing list