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

David Lutterkort lutter at redhat.com
Fri May 7 23:04:59 UTC 2010


On Thu, 2010-05-06 at 16:35 +0200, Frederik Wagner wrote:
> @David: I included all your earlier suggestions about single values
> w/o quotes and single as well as double quoted lists.

Yes, I am very happy that you got that to work.

> There are still two issues, where somebody might help:
> 1. escaped characters are not handled (i.e. in a double quoted list
> backpace escaped whitespaces or double quotes are not possible). This
> does not work by simply including them in the "dqchar" regexp. Why?!

You need to build a slightly more complicated regexp. For example,
Shellvars.dquot is

        let dquot = /"([^"\\\n]|\\\\.)*"/
        
In English: a double quoted string is a string that starts and ends with
'"', and contains any individual character except for '"' and '\n' or
any two-character sequence '\.' - might take a little to wrap your head
around ;)

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
      ...

> 2. When adding new values, the 'quote' key (defining the type of
> quotes used) has to be added _before_ any other value. I do not
> understand why the tree has to be sorted?

The Augeas tree is orderd, i.e. the order in which nodes appear in a
tree matters - that's a consequence of the fact that the tree reflects a
file, which itself is ordered. 

It would sometimes be nice, like in this case, to say "don't worry where
the 'quote' node appears, always act as if it were the first
node" (i.e., output the quote character before outputting any 'value'
nodes), but there's no way to do that in Augeas currently. Would be a
nice addition though[1] ;)

David

[1] Boomerang (http://www.seas.upenn.edu/~harmony/) has functionality to
sort etc.





More information about the augeas-devel mailing list