[augeas-devel] [PATCH] List handling shellvars_list lens added.
David Lutterkort
lutter at redhat.com
Fri May 7 22:56:26 UTC 2010
On Thu, 2010-05-06 at 16:29 +0200, Frederik Wagner wrote:
> Lens shellvars_list has been added to treat variables in specific files
> as lists of words, e.g. in /etc/sysconfig/ 'kernel' and 'bootloader'.
Very nice ... I am impressed you got this to work. I have a few small
comments:
> diff --git a/lenses/shellvars_list.aug b/lenses/shellvars_list.aug
> new file mode 100644
> index 0000000..25cbfc2
> --- /dev/null
> +++ b/lenses/shellvars_list.aug
> @@ -0,0 +1,54 @@
> +(* Generic lens for shell-script config files like the ones found *)
> +(* in /etc/sysconfig, where a string needs to be split into *)
> +(* single words. *)
> +module Shellvars_list =
> + autoload xfm
> +
> + let eol = Util.eol
> +
> + let key_re = /[A-Za-z0-9_]+/
> + let eq = Util.del_str "="
> + let comment = Util.comment
> + let empty = Util.empty
> + let indent = Util.indent
> +
> + let sqchar = /[^ '\t\n]/
> + let dqchar = /[^ "\t\n]/
> + let char = /[^ "'\t\n]/
> +
> + (* lists values of the form ... val1 val2 val3 ... *)
> + let list(ch:regexp) =
> + let list_value = store ch+ in
> + indent . counter "values" .
> + [ seq "values" . list_value ] .
> + [ del /[ \t\n]+/ " " . seq "values" . list_value ]* . indent
I would prefer if you don't use 'seq' here - the tree is a little easier
to handle if you just stick with a fixed label, like 'value' or some
such.
I've attached a patch on top of yours that makes the change I have in
mind - if you are ok with that, I'll commit both patches.
David
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Shellvars_list-switch-from-seq-to-fixed-label-for-va.patch
Type: text/x-patch
Size: 5447 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/augeas-devel/attachments/20100507/7bb16241/attachment.bin>
More information about the augeas-devel
mailing list