[augeas-devel] shellvars - regex parsing help

David Lutterkort lutter at redhat.com
Mon Jan 11 20:11:42 UTC 2010


On Mon, 2010-01-11 at 14:01 -0500, Adam Stokes wrote:
> My regex skills are probably less than par but I'm having some trouble
> getting this comment var to work with shellvars.aug.
> 
> error in augtool:
> /augeas/files/etc/sysconfig/nfs/error = "parse_failed"
> /augeas/files/etc/sysconfig/nfs/error/pos = "0"
> /augeas/files/etc/sysconfig/nfs/error/line = "1"
> /augeas/files/etc/sysconfig/nfs/error/char = "0"
> /augeas/files/etc/sysconfig/nfs/error/lens = "/usr/share/augeas/lenses/dist/shellvars.aug:47.12-.45:"
> /augeas/files/etc/sysconfig/nfs/error/message = "Iterated lens matched less than it should"

First off, the error message 'Iterated lens matched less than it should'
means that you have a lens 'l*' somewhere that didn't consume all the
text that it should, i.e. got stuck somewhere. The lens node in the
error says that it's the lens defined on line 47, column 12-45 in
shellvars.aug.

The line and char node tell you that the problematic piece of text
starts at line 1, column 0 in file /etc/sysconfig/nfs - Augeas versions
before 0.6.0 had a bug that made that location less precise than it can
be. To pinpoint better which line is causing headaches, you might want
to upgrade to 0.6.0.

> current shellvars comment:
>   let key_re = /[A-Za-z0-9_]+(\[[0-9]+\])?/ - "unset" - "export"
>   let eq = Util.del_str "="
>   let empty   = Util.empty
>   let comment       = 
>     let line_re     = /(#[^ \t][^\n]*)?/ - (key_re . "=" . /.*/) in
>     [ label "#comment" . empty . store line_re . del /\n/ "\n" ]
> 
> David has been helping a lot with this and I know that line_re should
> match all '#.*' minus anything that looks like a setting though only
> limiting it to key_re . '=' . /.*/ is not the best way to handle this
> since other settings may be written as 'var:val'.

In your specific case, it is most likely that you have a line in that
file that is neither matched by comment nor by kv. To narrow this down
some more, I'd need to see the actual file that you are using.

A simple way to do this for yourself is to write yourself a module t.aug
that looks like

  module T
    let s = Sys.read_file "/etc/sysconfig/nfs"
    test Shellvars.lns get = ?

and run that through augparse. Then remove lines from your file, until
you are left with the one line that causes trouble (simply remove lines
at random and repeatedly run the file through augparse to get that)

Once you have the problematic line, it'll be much easier to see what
your lens is missing.

David





More information about the augeas-devel mailing list