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

Frederik Wagner fnerdwq at googlemail.com
Tue May 18 12:54:12 UTC 2010


On Tue, May 18, 2010 at 1:55 PM, Frederik Wagner <fnerdwq at googlemail.com> wrote:
> Hi David,
>
> 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:
>>> @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 ;)
>
> 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?
>
>>
>> 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.

I forgot the tests/Makefile.am. Last Patch attached.

Bye,
Frederik

>
>>
>>> 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.
>
> o.k., so a user has to know some structure of the lens.
>
>> 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] ;)
>
> yes it would, but for the moment I'm happy if I have this running so far :-)
>
> Hope the lens is o.k. now?!
>
> Thanks for the help and bye,
> Frederik
>
>>
>> David
>>
>> [1] Boomerang (http://www.seas.upenn.edu/~harmony/) has functionality to
>> sort etc.
>>
>>
>>
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0004-Shellvars_list-added-lens-to-tests-Makefile.am.patch
Type: text/x-patch
Size: 646 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/augeas-devel/attachments/20100518/bee2db05/attachment.bin>


More information about the augeas-devel mailing list