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

Jonas Eriksson jonas.j.eriksson at ericsson.com
Thu Jul 30 06:47:31 UTC 2009


On Wed, Jul 29, 2009 at 06:51:26PM +0200 David Lutterkort wrote:
> 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.

Ok, this is not good. I can see that this is now touched in the
schema tutorial which I should have checked with before
submitting this patch (which was written a while back).

Are there any thoughts on letting augeas have some sort of
writeback-awareness that would let it react to this? Some sort of
value-filter perhaps (foo bar => 'foo bar', fo'o => "fo'o").

> 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)

For general shellvars I can understand this, but now we have a
very much simplified case which would let us cut corners to
gravely simplify the C-code.

> > 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 ?

As said in 6/7, this needs to be handled for all variables, not
just the ones that can contain spaces. What I forgot to mention
in that mail is that I believe YaST (the default config tool for
SuSE) defaults to do the single-quoting on all ifcfg-values.

/Jonas

--
Jonas Eriksson
Consultant at AS/EAB/FLJ/IL
Phone: +46 8 58086281
Combitech AB
Älvsjö, Sweden


More information about the netcf-devel mailing list