[augeas-devel] shellvars - regex parsing help
Adam Stokes
ajs at redhat.com
Mon Jan 18 21:39:41 UTC 2010
----- "David Lutterkort" <lutter at redhat.com> wrote:
> On Thu, 2010-01-14 at 12:03 -0500, Adam Stokes wrote:
>
> The expression after the '-' is not right: you have
> /([ \t]key_re . [ \t]*=[ \t]*.*[ \t\n])/
>
> That's one literal regexp; you're missing a bunch of '/' to end/start
> regular expression literals.
>
> I think what you mean is
> /[ \t]*/ . key_re . /[ \t]*=[ \t]*.*/
>
> David
Once setting this as above augparse takes about 5 minutes longer to run through the test module:
shellvars.aug :
let key_re = /[A-Za-z0-9_]+(\[[0-9]+\])?/ - "unset" - "export"
let eq = Util.del_str "="
let empty = Util.empty
(* let comment = Util.comment *)
let comment =
let line_re = /([^ \t\n].*[^ \t\n]|[^ \t\n])/ - /[ \t]*/ . key_re . /[ \t]*=[ \t]*.*/ in
[ label "#comment" . del /#[ \t]*/ "# " . store line_re . del /\n/ "\n" ]
/etc/sysconfig/nfs
# THIS IS A COMMENT FOR MOUNTD
# TESTINGVAR=VAL
# MOUNTD_PORT=892
t.aug:
module T =
let s = Sys.read_file "/etc/sysconfig/nfs"
test Shellvars.lns get "# THIS IS A COMMENT FOR MOUNTD\n" =
{ "#comment" = "THIS IS A COMMENT FOR MOUNTD" }
test Shellvars.lns get "# TESTINGVAR=VAL\n" =
{"TESTINGVAR" = "VAL"}
test Shellvars.lns get "# MOUNTD_PORT=892\n" =
{"MOUNTD_PORT" = "892"}
error reported by augparse:
[root at jak dist]# augparse t.aug
t.aug:5.4-6.28:exception thrown in test
t.aug:5.9-.47:exception: Iterated lens matched less than it should
Lens: /usr/share/augeas/lenses/dist/shellvars.aug:48.12-.53:
Error encountered at 1:0 (0 characters into string)
<|=|# TESTINGVAR=VAL\n>
Tree generated so far:
t.aug:7.4-8.29:exception thrown in test
t.aug:7.9-.48:exception: Iterated lens matched less than it should
Lens: /usr/share/augeas/lenses/dist/shellvars.aug:48.12-.53:
Error encountered at 1:0 (0 characters into string)
<|=|# MOUNTD_PORT=892\n>
Tree generated so far:
No error
--
__ __
.-----.| |_.-----.| |--.-----.-----.
|__ --|| _| _ || <| -__|__ --|
|_____||____|_____||__|__|_____|_____|
.----------------------------------.
( ajs at redhat.com || 919.754.4187 )
`----------------------------------'
More information about the augeas-devel
mailing list