[augeas-devel] Optional quotes with square lens
Raphaël Pinson
raphael.pinson at camptocamp.com
Sat Oct 27 09:00:09 UTC 2012
Actually, what if I wanted to allow spaces in the value, but only if it is
surrounded by quotes?
I've tried this:
let entry =
let lquote = del /("[\t ]*)?/ "\""
in let rquote = del /([\t ]*")?/ "\""
in let body = store /[^\n\t "]([^\n"]*[^\n\t "])?/
in let sto = square lquote body rquote
in Build.key_value_line Rx.word Sep.space_equal sto
but augparse says:
lenses/vmware_config.aug:28.15-.40:exception: Inconsistency in lens square
I guess the problem is that opening and closing quotes should match, which
doesn't make sense if the spaces are included in them… Is there a way to do
this?
Raphaël
On Sat, Oct 27, 2012 at 10:44 AM, Raphaël Pinson <
raphael.pinson at camptocamp.com> wrote:
>
>
> On Sat, Oct 27, 2012 at 1:05 AM, David Lutterkort <lutter at redhat.com>wrote:
>
>> On Fri, 2012-10-26 at 15:50 +0200, Raphaël Pinson wrote:
>> > Hello,
>> >
>> >
>> > I'm trying to use the square lens to manage entries with optional
>> quotes:
>> >
>> > let entry =
>> > let quote = del /"?/ "\""
>> > in let body = store /[^\n"]+/
>> > in let sto = square quote body quote
>> > in Build.key_value_line Rx.word Sep.space_equal sto
>> >
>> >
>> > This works with quoted entries, but not with entries that don't have
>> > quotes, such as:
>> >
>> > key = value
>>
>> There's a bug in how the ctype for square lenses gets rewritten - it
>> doesn't account for the first argument of square accepting the empty
>> word, making your quote in effect del /"/ "\""
>>
>> I've fixed that in commit 51922f9b
>>
>
>
> Great, it works now. Thank you!
>
>
> --
> Raphaël Pinson
> Administrateur Systèmes & Réseaux
> Camptocamp France
> Savoie Technolac
> BP 352
> 48, avenue du Lac du Bourget
> 73372 Le Bourget du Lac, Cedex
> www.camptocamp.com
>
>
--
Raphaël Pinson
Administrateur Systèmes & Réseaux
Camptocamp France
Savoie Technolac
BP 352
48, avenue du Lac du Bourget
73372 Le Bourget du Lac, Cedex
www.camptocamp.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/augeas-devel/attachments/20121027/45a04b28/attachment.htm>
More information about the augeas-devel
mailing list