[augeas-devel] [PATCH] List handling shellvars_list lens added.

David Lutterkort lutter at redhat.com
Tue May 18 19:54:04 UTC 2010


On Tue, 2010-05-18 at 13:55 +0200, Frederik Wagner wrote:
> On Sat, May 8, 2010 at 1:04 AM, David Lutterkort <lutter at redhat.com> wrote:
> > On Thu, 2010-05-06 at 16:35 +0200, Frederik Wagner wrote:
> >> 
> > You need to build a slightly more complicated regexp. For example,
> > Shellvars.dquot is
> >
> >        let dquot = /"([^"\\\n]|\\\\.)*"/
> >
> yes... hmm, but I'm not sure why in '\\\\.' 4 backslashes are needed
> for the the ecpade chars (it only works like this, but I don't get it
> clear). Can you give me a hint?

The regular expression you want to wind up with is "\\.", in English
'match a \ followed by a .' - if the regexp was only '\.' it would only
match a literal '.'.

The parser for the Augeas language does unescaping, e.g. translating the
two character string "\n" into the character '\n' - as part of that, it
collapses the two character string "\\" to the character '\'.

That means, to get "\\." in your regular expression, you need to escape
each backslash with another one, giving you /\\\\./

> > For your lens, you'd have to change list to take the full regexp for the
> > word you're parsing, e.g. /([^"\\\n]|\\\\.)*/ instead of an individual
> > character; something like (warning: not tested)
> >
> >   let list(word:regexp) =
> >      let list_value = store word in
> >      ...
> 
> Done.
> I included your patch and the extended the escaped char handling.
> Find attached the two patches on top of my original patch.

Thanks a ton. I've applied your additional patches, and squashed
everything into one patch and pushed that.

David





More information about the augeas-devel mailing list