[augeas-devel] load specific lens

Frederik Wagner fnerdwq at googlemail.com
Wed Mar 10 15:25:33 UTC 2010


On Wed, Mar 10, 2010 at 9:46 AM, Frederik Wagner <fnerdwq at googlemail.com> wrote:
> 2. Would there be a way to inlcude the 'string' array handling into
> the shellvars lens? Probably only by handling specific entries of
> specific files (how do I test for the scanned file in a lens?)
> diferently, I suppose?

As a (working) test I included the functionality into the shellvars
lens to treat specific keywords as an array of words.
This works fine (even if one has to keep an explicit list of keywords
which have to be treated in this way), but for the fact that the lens
is _incredibly_ slow now and using a _lot_ of memory.

To filter or the keywords I'm using - just showing the relevant adjustments:

...
  (* keywords from files which should be treaded as array of words *)
  let key_wa =
               (* from /etc/sysconfig/kernel *)
               "MODULES_LOADED_ON_BOOT"
             | "DOMU_INITRD_MODULES"
             | "INITRD_MODULES"
               (* from /etc/sysconfig/bootloader *)
             | "DEFAULT_APPEND"
             | "FAILSAFE_APPEND"
             | "XEN_KERNEL_APPEND"
             | "XEN_APPEND"
             | "RT_APPEND"

  let key_re = /[A-Za-z0-9_]+(\[[0-9]+\])?/ - "unset" - "export" - key_wa
...

and later in the lens I'm applying extras steps to the filtered keywords:

...
  let char_wa = /[^ "\t\n]/

  (* for the keywords in key_wa treat the values as an array of words *)
  let wa_array = let char_wa = /[^ "\t\n]/
    let wa_array_value = store char_wa+ in
    del /\"[ \t]*/ "\"" . counter "wa_val" .
      [ seq "wa_val" .wa_array_value ] .
      [ del /[ \t\n]+/ " "  . seq "wa_val" . wa_array_value ] *
      . del /[ \t]*\"/ "\""

  (* lens for the array of words, extra handling of empty strings "" *)
  let wa_kv = [ key key_wa . eq . (del "\"\"" "\"\""|wa_array) . eol ]

  let lns = ( comment | empty | source | kv | unset | wa_kv ) *
...

Since I change the fast working original shellvars lens, I suppose the
filtering construct is the problem.

Am I doing something wrong? Or is the adjustment of the shellvars lens
generally not usefull anyway? (if it is I would submit the patch, when
I'm ready).

Thanks a lot and by,
Frederik




More information about the augeas-devel mailing list