[augeas-devel] [PATCH] Mdadm_conf: new lens for /etc/mdadm.conf

Matthew Booth mbooth at redhat.com
Mon Nov 14 13:05:17 UTC 2011


On 14/11/11 03:52, David Lutterkort wrote:
> On Mon, 2011-11-07 at 16:53 +0000, Matthew Booth wrote:
>> ---
>>   lenses/mdadm_conf.aug            |  281 ++++++++++++++++++++++++++++++++++++++
>>   lenses/tests/test_mdadm_conf.aug |   96 +++++++++++++
>>   2 files changed, 377 insertions(+), 0 deletions(-)
>>   create mode 100644 lenses/mdadm_conf.aug
>>   create mode 100644 lenses/tests/test_mdadm_conf.aug
>
> ACK. I was going to get all grouchy about this:
>
>
>> +let dev_containers_re = /[cC][oO][nN][tT][aA][iI][nN][eE][rR][sS]/
>> +let dev_partitions_re = /[pP][aA][rR][tT][iI][tT][iI][oO][nN][sS]/
>
> since there is now syntax for case-insensitive regexps, i.e. you can
> write
>
>          let dev_containers_re = /containers/i
>          let dev_partitions_re = /partitions/i
>
> but then realized that a bug in the code that handles case-insensitive
> regexps causes the regular expression in
>
>> +let dev_device = [ label "name". store ( value
>> +                                         - dev_containers_re
>> +                                         - dev_partitions_re ) ]
>
> to be incorrect (it matches 'containerS' and 'partitionS') which makes
> the lens fail typechecking.

I mentioned the bug in a comment ;) I originally started using 
case-insensitive matches, but had to abandon it.

> I committed the lens as-is. When I fix the bug described above, I'll fix
> up the lens to use the more readable regexp syntax.

I'll be interested in that fix. I was actually trying to do something a 
bit more ambitious with this lens: write a lens which would parse *any* 
file, but which put invalid content into an #error node in the 
appropriate context. As an example of how I was trying to do this, I 
wanted to match initial keywords something like this:

let foo_re = /foo/i
let bar_re = /bar/i
let error_re = word - foo - bar

This wasn't working for me with a non-trivial example, with or without 
case-insensitive regular expressions, and I couldn't make head nor tail 
of the error messages as the resulting regexps were enormous.

Matt
-- 
Matthew Booth, RHCA, RHCSS
Red Hat Engineering, Virtualisation Team

GPG ID:  D33C3490
GPG FPR: 3733 612D 2D05 5458 8A8A 1600 3441 EA19 D33C 3490




More information about the augeas-devel mailing list