[augeas-devel] Re: [config-model-users] Semantic problem in augeas sshd lens ?

David Lutterkort dlutter at redhat.com
Fri Aug 1 17:05:37 UTC 2008


On Fri, 2008-08-01 at 15:05 +0200, Raphaël Pinson wrote:


>         And this notation is only valid for "leaf". As "higher" level
>         arrays like
>         /etc/host/ use another notation even with only one element in
>         the array:
>         
>         augtool> print /files/etc/hosts
>         /files/etc/hosts
>         /files/etc/hosts/1
>         /files/etc/hosts/1/ipaddr = "127.0.0.1"
>         /files/etc/hosts/1/canonical = "localhost"
>         /files/etc/hosts/1/alias = "localhost"
> 
> 
> No, this is not another notation. /files/etc/hosts/1
> and /files/etc/hosts/2 are not two /etc/hosts files ;) In the first
> case, Subsystem was declared using "label" (or most likely "key",
> which gives the same result), resulting in the same of the label being
> used to refer to an array of values. In the second case, "seq" was
> used because the file is only made of the same kind of entries. It
> could have been made into :
> 
> /files/etc/hosts/entry
> /files/etc/hosts/entry/ipaddr = "127.0.0.1"
> /files/etc/hosts/entry/canonical = "localhost"
> /files/etc/hosts/entry/alias = "localhost"
> 
> which would then give trees like /files/etc/hosts/entry[1]
> and /files/etc/hosts/entry[2] in the case of multiple entries, but
> since there's only one kind of entry, it's really useless, hence the
> use of numbers only to refer to lines (although I'm not a big fan of
> "seq", I find it harder to parse the tree).

I agree with that, and thought about removing 'seq' completely at some
point. The reason it's still there has to do with how whitespace is
preserved: if you have two lines in your /etc/hosts and you do a
'rm /files/etc/hosts/1', the remaining line will be restored exactly as
it was before, because the whitespace for it is keyed off the label of
the node ('2' when using 'seq')

If you don't use seq and use multiple 'entry' labels instead, and you do
'rm /files/etc/hosts/entry[1]', when you save the tree, the remaining
line will use the whitespace from the first line, since for multiple
identical labels, the whitespace  is put on a list, and that list is
consulted in order as entries are restored.

That is the only reason I still use 'seq' - if it weren't for that I
would have removed it completely.

David






More information about the augeas-devel mailing list