[augeas-devel] [PATCH] Array handling shellvars_array lens added.

Frederik Wagner fnerdwq at googlemail.com
Tue Apr 13 13:29:39 UTC 2010


On Fri, Mar 26, 2010 at 1:45 AM, David Lutterkort <lutter at redhat.com> wrote:
> On Tue, 2010-03-23 at 21:38 +0100, Frederik Wagner wrote:
>> Lens shellvars_array has been added to treat  variables in specific
>> files as array of words, e.g. in /etc/sysconfig/ 'kernel' and
>> 'bootloader'.
>>
>> * lenses/shellvars.aug:
>>     removed include for /etc/sysconfig/kernel
>> * lenses/shellvars_array.aug:
>>     new lens
>> * lenses/tests/test_shellvars_array.aug:
>>     test for new lens
>
> This doesn't quite do what you want it to do yet. With the
> following /etc/sysconfig/kernel:
>
>        # UPDATEDEFAULT specifies if new-kernel-pkg should make
>        # new kernels the default
>        UPDATEDEFAULT=yes
>
>        # DEFAULTKERNEL specifies the default kernel package type
>        DEFAULTKERNEL=kernel-xen
>
> I get the following complaint from augtool:
>
>        /augeas/files/etc/sysconfig/kernel/error = "parse_failed"
>        /augeas/files/etc/sysconfig/kernel/error/pos = "82"
>        /augeas/files/etc/sysconfig/kernel/error/line = "3"
>        /augeas/files/etc/sysconfig/kernel/error/char = "0"
>        /augeas/files/etc/sysconfig/kernel/error/lens = "/homes/lutter/code/augeas/lenses/shellvars_array.aug:27.12-.37:"
>        /augeas/files/etc/sysconfig/kernel/error/message = "Iterated lens matched less than it should"
>
> It seems the lens does not allow entries that are not enclosed in
> quotes. Also, how will it handle single-quoted lists, like
>
>        VAR='val1 val2 val3'

you are right: the lens is not handling anything else then double
quote enclosed entries.
I'm already playing around quit a while here, but don't manage to get
single quote or no quotes at all included. I get complaints of the
form
"Iterated lens matched less than it should" (in a lot of cases...) or
for a construct like:

  let array =
    let array_value = store char+ in
    (del /"/ "\"" | del /'/ "'" ) . indent. counter "values" .
      [ seq "values" . array_value ] .
      [ del /[ \t\n]+/ " "  . seq "values" .array_value ] *
      . indent . (del /"/ "\"" | del /'/ "'")

I get the error "overlapping lenses in tree union.put".

I'm lost... ;-)

And not even startetd fixing the case w/o quotes.

>
> It might be better to call the construct you are using a list to
> distinguish it from the arrays that the shell already supports. But I
> generally like the direction this lens is taking.

naming it "shellvars_list" is fine for me.


Bye,
Frederik

>
> David
>
>




More information about the augeas-devel mailing list