[netcf-devel] [PATCH 7/7] Let the lens handle single quotes instead of the XSLT and XSLT extensions

David Lutterkort lutter at redhat.com
Wed Jul 29 16:51:26 UTC 2009


On Thu, 2009-07-23 at 14:37 +0200, Jonas Eriksson wrote:
> This is the second in a two-stage commit where we move from
> the standard shellvars-lens to one that strips the single
> quotes before and after strings.
> 
> data/lenses/ifcfg.aug: Strip single (and double) quotes and
>   re-insert them after save.

This doesn't work properly - when you modify a lens, you should also run
it through 'augparse data/lenses/ifcfg.aug' to typecheck it, and the
modified lens produces a typechecking error (typechecking isn't done by
default since it can be _very_ slow)

The typecheck error from augparse is

        data/lenses/ifcfg.aug:22.2-27.19:Failed to compile array
        data/lenses/ifcfg.aug:23.22-.42:exception: overlapping lenses in tree union.put
            Example matched by both: ''
            First lens: data/lenses/ifcfg.aug:16.15-.59
            Second lens: data/lenses/ifcfg.aug:23.31-.42
        
The issue is that Augeas can't decide how to write out variable values
when it goes from tree -> file. For a variable VAR with value VAL in the
tree, Augeas can legally write this as VAR=VAL, VAR='VAL', or VAR="VAL"
- and it has no way of knowing which one is correct. For example, if VAL
contains spaces, no quotes would be incorrect.

That's the reason why the shellvars lens doesn't strip quotes
automatically :) (Plus, in general, it matters when you look at an entry
in the tree whether it's enclosed in single or double quotes, and
there's no way to decide automatically which one is correct)

> data/xml/util-get.xsl: Remove insertion of single quotes in XSLT

If this is just for simplification, I would just drop this patch and 6/7
- otherwise, what problem did you run into ?

David




More information about the netcf-devel mailing list