[augeas-devel] Having trouble differentiating quoted vs unquoted string

David Lutterkort lutter at redhat.com
Fri Aug 14 01:36:47 UTC 2009


On Thu, 2009-08-13 at 12:39 +1000, Matthew Palmer wrote:
> That's ugly and prone to error, but I could talk my way into doing that if I
> absolutely had to.  However, there are other SSH options that can be a
> comma-separated list of value, which then need to be quoted (but not
> necessarily, if you've only got one value to set that doesn't contain
> spaces).  That one we can't trick with leaving the quotes in place...

Yeah, for those cases, you'll want raphink's way to strip quotes and
commas and parse each value into a separate tree node.

> So, here's my "test" lens for the simple quoted/unquoted line scenario
> (though using single quotes as the quoting character, to simplify the
> escaping):
> 
> let unquoted_line = seq "count" . del /'?/ "" . store /[^' \t\n][^' \t\n]*/ . del /'?/ ""
> 
> let quoted_line = seq "count" . Util.del_str "'" . store /[^'\n]* [^'\n]*/ . Util.del_str "'"
> 
> let line = (unquoted_line|quoted_line) . Util.eol
> 
> let lns = line*
> 
> However, augparse tells me that this is overlapping, and that '' (exactly
> that -- the single quotes there are augparse's, not mine) matches both. 
> I've got an explicit and required space character in the middle there, so
> how can that second regexp (in quoted_line) match the empty string?

That's again the issue that Augeas only looks at labels, not values in
the tree -> file direction; therefore, unquoted_lines and quoted_lines
are the same for purposes of type-checking the tree -> file direction,
namely just 'seq "count"'

It prints the empty string because the typecheck error happens at the
'|' in the line lens: for checking the tree -> file direction for a
construct l1|l2, Augeas looks at the trees that l1 generate and the
trees that l2 generate, and checks that the labels of their toplevel
nodes are always disjoint. Your lenses don't contain any [...]
constructs, i.e. they do not generate any tree nodes (seq and store just
mark stuff to use as the label and value of the next tree node that gets
constructed) - hence both lenses in your example create the empty tree,
which winds up being printed as ''.

David





More information about the augeas-devel mailing list