help-cfengine
[Top][All Lists]
Advanced

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

Re: non-convergent file edit?


From: Mark . Burgess
Subject: Re: non-convergent file edit?
Date: Wed, 17 Mar 2004 20:33:25 +0100 (MET)

So now someone has a weekend programming project to solve ;)

M

On 17 Mar, rader@ginseng.hep.wisc.edu wrote:
> 
>  > > > 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
> 
> 
> 
> _______________________________________________
> Help-cfengine mailing list
> Help-cfengine@gnu.org
> http://mail.gnu.org/mailman/listinfo/help-cfengine



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Work: +47 22453272            Email:  Mark.Burgess@iu.hio.no
Fax : +47 22453205            WWW  :  http://www.iu.hio.no/~mark
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~





reply via email to

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