[augeas-devel] New lens primitive value

David Lutterkort lutter at redhat.com
Sat Jan 16 00:32:09 UTC 2010


On Fri, 2010-01-15 at 23:45 +0100, Tim Stoop wrote:
> Hi David,
> 
> On Fri, Jan 15, 2010 at 8:34 PM,  <lutter at redhat.com> wrote:
> > This adds a new lens primitive 'value'. It is the counterpart of the label
> > lens in that it sets the value of a tree node to a constant, rather than
> > the label.
> 
> Thanks for that! At least I assume this is in response to my previous email ;-)
> 
> Any tips on how to use this for my [OR] situation? As an example:
> 
> RewriteCond %{var} val [OR]
> RewriteCond %{var} lue
> 
> How do I say, "if the line ends in [OR], add a { "chain_as" = "or" },
> otherwise add a { "chain_as" = "and" }?

One way to do that is like this:

        module Chain =
        
        let word = /[^ \t\n]+/
        let ws = del /[ \t]+/ " "
        let lns = [ key "RewriteCond" . ws .
                      [ label "eq" . store word ] . ws . store word .
                      ([ label "chain_as" . ws . del "[OR]" "[OR]" . value "or"]
                      |[ label "chain_as" . value "and" ]) ]
        
        test lns get "RewriteCond %{var} val [OR]" =
          { "RewriteCond" = "val"
            { "eq" = "%{var}" }
            { "chain_as" = "or" } }
        
        test lns get "RewriteCond %{var} lue" =
          { "RewriteCond" = "lue"
            { "eq" = "%{var}" }
            { "chain_as" = "and" } }
        
Be warned though, the patch I posted for value has a little bug; you
need to apply the attached incremental patch.

David

-------------- next part --------------
A non-text attachment was scrubbed...
Name: value.patch
Type: text/x-patch
Size: 440 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/augeas-devel/attachments/20100115/7ac20a8c/attachment.bin>


More information about the augeas-devel mailing list