[augeas-devel] Non-empty string from get has turned into empty node for put direction - why?

David Lutterkort lutter at watzmann.net
Wed Feb 24 00:13:30 UTC 2016


On Mon, Feb 22, 2016 at 11:53 PM, Mol, Xavier (SCC) <xavier.mol at kit.edu>
wrote:

> Hello David,
>
>
>
> thank you for your helpful explaination. This is what I have learned from
> it:
>
>
>
> - Use '[ lns . bare ] | [ lns . quoted ]' if lns will have different
> labels/keys in either situation.
>

Yes, that's correct; note that you can't use the exact same 'lns' in both
branches above as those will always have the same labels. But something
like '[key "x" . bare] | [key "y" . quoted]' definitely works.


> - Use '[ lns . ( bare | quoted ) ]' when the keys/labels will be identical
> anyway.
>

Yes, exactly.


> Even though Augeas does not make decisions solely based on the
> keys/labels, that is the primary guideline. Is this correct?
>

Yes, the ugly truth is that for a tree node with label L and value V,
Augeas looks at that roughly as the string 'L=V' and decides whether a lens
applies to that node depending on whether the regular expression for that
lens (the 'abstract type' or 'atype' in the code) matches the string 'L=V';
IOW, Augeas could also distinguish between tree nodes that have the same
label but different values. I just left that out in my original email since
it seemed too arcane. And what actually happens is that Augeas doesn't
construct that string as 'L=V' but rather uses special characters \003 and
\004 and constructs 'L\003V\004' (defined in lens.h as ENC_EQ and
ENC_SLASH) It does that to not get fooled by '=' signs that might be in L
or V (or both).

Just to clarify more, the example from the Wiki would work the same if you
wrote it as

    let a = label "x" . value "a" . [ label "color" . store /red|blue/ ]
    let b = label "x" . value "b" . [ label "color" . del /dark-/ "dark-" .
store /red|blue/ ]

    let lns = [ a ]|[ b ]

Here, Augeas basically needs to distinguish between 'x=a' and 'x=b', which
it can without any problems.

When you write '[a | b]' in the above, Augeas knows that it should use that
lens whenever a node (as a string) matches /x=(a|b)/ but when it is then
'inside' and tries to apply 'a|b' to the 'color' node, it can' tell whether
it should use the version from 'a' or 'b'.

With a sligthly different explaination, I've written documentation on the
> error "overlapping lenses in union.put" on the Augeas wiki (
> https://github.com/hercules-team/augeas/wiki/List-of-frequent-errors#overlapping-lenses-in-unionput).
> The key argument there, too, is, that the keys for the tree nodes must be
> different to make Augeas happy.
>

Awesome ! This is great !

On a tangential note, I've wanted for a long time to revamp the docs and
make it easier to update them. Unfortunately, I used a silly set of tools
when I first wrote http://augeas.net/ and simply haven't had the time to
work on changing the website from that silly tooling to something simpler,
like a static site generator based on markdown.

David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/augeas-devel/attachments/20160223/0cfe764b/attachment.htm>


More information about the augeas-devel mailing list