[augeas-devel] Distinguishing empty string from no value in path expressions

Michael Chapman mike at very.puzzling.org
Wed Sep 28 04:33:58 UTC 2011


Hi,

With Augeas's path expressions, is it possible to distinguish a node whose 
value is an empty string from one that has no value? At the moment, nodes 
with no value appear to be treated the same as those with an empty string:

augtool> set /test/a ''
augtool> clear /test/b
augtool> match /test/*
/test/a =
/test/b = (none)
augtool> match /test/* ''
/test/a =
/test/b = (none)
augtool> match /test/*[.='']
/test/a =
/test/b = (none)
augtool> match /test/*[.=~regexp('')]
/test/a =
/test/b = (none)

There are some lenses that treat these kinds of nodes differently. For 
instance, in grub.aug we have:

     (* Parse the file name and args on a kernel or module line. *)
     let kernel_args =
       let arg = /[A-Za-z0-9_.\$-]+/ - /type|no-mem-option/  in
       store /(\([a-z0-9,]+\))?\/[^ \t\n]*/ .
             (spc . multiboot_arg)? .
             (spc . [ key arg . (eq. store /([^ \t\n])*/)?])* . eol

so the kernel arguments "key" and "key=" yield different trees.

- Michael




More information about the augeas-devel mailing list