[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: best way to express an 'editfiles' idiom?
From: |
Daniel Pittman |
Subject: |
Re: best way to express an 'editfiles' idiom? |
Date: |
Mon, 21 Jul 2003 14:27:43 +1000 |
User-agent: |
Gnus/5.090016 (Oort Gnus v0.16) XEmacs/21.5 (cassava) |
On Mon, 21 Jul 2003, Jamie Wilkinson wrote:
> This one time, at band camp, Daniel Pittman wrote:
>>When I manage configuration files with cfengine, I frequently find
>>myself wanting to express the following action with 'editfiles':
>>
>> Make every line matching "^Value" equal to "Value foo"
>
> What I do is a little more verbose, and behaves a little differently
> to your method:
[...]
> This copes with values that exist in the config file but are set
> incorrectly, and also doesn't try to modify lines that are already
> correct (The BeginGroupIfNoMatch is set to the whole line so that
> ReplaceLineWith doesn't do any editing unless necessary).
*nod* That's pretty much what I tried to achieve, and seems to do the
right thing. It's still a couple of lines for every value, and if I want
to set ten or more of them, that's *really* ugly.
OTOH, I don't really want to use 'copy' for a number of these files,
because that is a pain when postfix adds a new daemon, for example, or
with a config file for Squid or something.
Something like the field based replace code would work well, I think, if
it was intended to set a semi-structured key/value pair -- and that is a
very common Unix idiom.
Daniel
--
The great end of life is not knowledge, but action. What men need is as much
knowledge as they can organize for action; give them more and it may become
injurious. Some men are heavy and stupid from undigested learning.
-- Thomas Henry Huxley