augeas - reading/modifying/writing system configuration files

David Lutterkort dlutter at redhat.com
Mon May 5 18:05:10 UTC 2008


On Mon, 2008-05-05 at 13:38 -0400, David Malcolm wrote:
> The other thing that doesn't seem to have been mentioned yet: how well
> does augeas preserve whitespace/comments etc when writing changes back
> out? (to play well with hand-edited config files)

Heh .. yeah, forgot to mention the point that caused most of the pain in
implementing: keeping comments, formatting detail etc. is incredibly
important and Augeas works very hard to meet an intutitve notion of
"minimal edit". At the same time, it does not rely on any
Augeas-specific annotation in the files, so that you can freely
interleave changing a file with Augeas with any other means of changing
it (from vi to your favorite Perl script)

> I got the impression reading the web site that it does this "for free"
> once you've written the input lens.  (how well does it work?)

The files tests/*.rb[1] in the mercurial repo contain examples of how
changes to the tree correspond to changes in files. Diffs in those files
are against files in tests/root/ from the mercurial repo.

> I suspect that a hand-coded parser typically won't do as good a job of this.

Yeah, it's painful (I tried) It's also where the "original" parser from
whatever consumes those config files becomes useless for editing: they
typically discard all that information (as they should; there's no need
to hang on to that information if you're only reading config data)

David


[1]
http://hg.et.redhat.com/misc/augeas?cmd=manifest;manifest=04452485c2e89a718d09bfa6fe377da1fb9244b1;path=/tests/





More information about the devel mailing list