[augeas-devel] [PATCH] Support empty comments, like lines beginning with "; " or "#" but without any more text

David Lutterkort lutter at redhat.com
Wed Aug 27 18:56:22 UTC 2008


On Wed, 2008-08-27 at 12:48 +0200, Raphaël Pinson wrote:


> Now that's where I was left experimenting last week, and was down to
> that same state. But then, I did something like this (which I cannot
> do right now because I've played so much that my inifile.aug is broken
> on this machine ;)).
> 
> * fire up augtool 
> * print an INI File with empty comments in it ('# \n' for example)
> * change a value in this INI File (whatever value, really)
> * save
> 
> When I tried this, augeas refused to save (since version 0.3.0, it
> worked before), saying that NULL is not a proper value for the
> "#comment" node. I've since tried with other stuff, like empty values
> in dput.aug (e.g. 'pre_upload_command =', which is fine) and get the
> same result.
> 
> Could you try it on your side Free?

I just tracked that down to a bug and a shortcoming: the bug is that the
typecheck of the '?' operator does not check the tree -> file direction;
the shortcoming is that Augeas looks solely at the labels of tree nodes
to figure out if a lens applies to a tree or not, i.e. it doesn't take
values into account.

For a lens '(store /[a-z]+/)?' Augeas doesn't really know whether it
should use the store lens or not - the way put is implemented, it really
needs to reject that construct.

In the example you had, what happens is that for a line like '# \n',
Augeas parses that skipping the store, since there is nothing to store,
and the resulting comment node has a NULL value associated with it. When
you try to put the tree, Augeas gets confused and tries to do a store on
the tree node with the NULL value, and then complains because you can't
do a store of NULL.

To fix this, there are two things to do: (1) add the missing typecheck
for the '?' operator so that typechecking actually checks the current
behavior (2) make the tree -> file transformation much smarter so that
it takes the value of nodes into account and so that '(store /[a-z]+/)?'
becomes legal.

(1) is very easy to implement, but will cause a lot of headache to fix
up existing lenses; (2) is a little harder, and I need to think about
that some.

David






More information about the augeas-devel mailing list