help-cfengine
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: non-convergent file edit?


From: rader
Subject: Re: non-convergent file edit?
Date: Wed, 17 Mar 2004 08:53:17 -0600

 > > > editfiles:
 > > > 
 > > >    { /etc/motd
 > > >        LocateLineMatching "year is [[:digit:]]{4}"
 > > >        ReplaceLineWith "year is $(year)
 > > >    }
 > > > 
 > > > If your script is convergent it will only happen once anyway.
 
 > >Sorry, doesn't work for me.  In perl terms, I want...
 > >
 > > s/year is \d{4}/year is $year/
 > >
 > >or more verbosely...

 > Let me put it this way:  the above editfiles construct is close to what
 > you're after, working out the details of the regex is up to you.

Nope, still won't do: that doesn't substitute parts of the existing
line into the new line.  The equiv perl code is...

 if ( $_ =~ /year is \d{4}/ ) { $_ = "year is $year"; }

...which is very different from...

  $_ =~ s/^(.*?)year is \d{4}(.*)$/${1}year is ${year}${2}/;

I really don't think there is any way to do s/regexp/newstring/ in
cfengine, and I think such a capability is desirable.  Someone please
correct me if I'm wrong, else let's declare this horse dead *and*
thoroughly flogged!!!

steve 
- - - 
systems & network guy
high energy physics
university of wisconsin





reply via email to

[Prev in Thread] Current Thread [Next in Thread]