[augeas-devel] Malformed child node when putting w/ ShellVars_list

Francis Giraldeau francis.giraldeau at gmail.com
Wed Jun 1 21:11:32 UTC 2011


> I'm using Augeas 0.7.4 and wrote a little stub lens to use
> ShellVars_list on
> /etc/conf.d/modules in Gentoo.
> 
> I'm trying to put a value to the modules_2_6 variable; this is the
> output of a
> test session (there is currently no modules_2_6 set):
> 
> # augtool
> augtool> set /files/etc/conf.d/modules/modules_2_6[last()+1] junk0
> augtool> save
> Saving failed
> augtool> ls /augeas/files/etc/conf.d/modules/error/
> path = /files/etc/conf.d/modules
> lens = /usr/share/augeas/lenses/dist/shellvars_list.aug:40.12-.37:
> message = Malformed child node 'modules_2_6'

Here is a small lens that shows the parsing of the text with
shellvars_list.aug: 

module Gentoo =

test Shellvars_list.lns get "modules_2_6=\"junk0\"\n" = ?
test Shellvars_list.lns get "modules_2_6=junk0\n" = ?

It produces this: 

Test result: gentoo.aug:3.0-.57:
  { "modules_2_6"
    { "quote" = """ }
    { "value" = "junk0" }
  }

Test result: gentoo.aug:4.0-.53:
  { "modules_2_6"
    { "quote" = "" }
    { "value" = "junk0" }
  }

Hense, three nodes must be set. The first one, "modules_2_6" doesn't
have a value. Children nodes "quote" and "value" must exists, and quote
node must be before any value nodes (the order matters). 

Here is an example to create this string from scratch:

test Shellvars_list.lns put "" after 
	clear "/modules_2_6";
	set "/modules_2_6/quote" "\"";
	set "/modules_2_6/value" "junk0" = "modules_2_6=\"junk0\"\n"

For multiple values: 

test Shellvars_list.lns put "" after 
	clear "/modules_2_6";
	set "/modules_2_6/quote" "\""; 
	set "/modules_2_6/value" "junk0";
	set "/modules_2_6/value[last()+1]" "junk1" = "modules_2_6=\"junk0 junk1
\""

Cheer, 

Francis




More information about the augeas-devel mailing list