On Sat, Apr 19, 2003 at 12:12:38PM -0400, Joey Hess wrote: > cvsd.conf is a trivial config file to parse and modify from what I can > see. > > port=`sed -n 's/^Port *\([^ ]*\).*$/\1/p' < /etc/cvsd/cvsd.conf` > > That's a reasonable way to get any value from it. I'm glad you do this
What about writing values? I imagine that changing the value of port might be as simple as: sed 's/^Port .*$/Port xyz/g' < /etc/cvsd/cvsd.conf > /etc/cvsd/cvsd.conf.new mv /etc/cvsd/cvsd.conf.new /etc/cvsd/cvsd.conf (not tested). However, what if (and I haven't looked at cvsd; some of my examples may not make sense for cvsd): - There is more then one Port setting? (its probably illegal here). Do you change all of them, or only the first one, or what? - There is no Port setting and one needs to be added? Is it OK to blindly add at the end of the file, or should a script try some black magic to work out the best spot? - Adding a port setting destroys the config, because the adminstrator deliberatly deleted that setting for some reason (I am assuming this would mean something, eg. only bind to a UNIX stream socket, for instance). - The system adminstrator accidently or deliberately commented out the port setting, and puts it back in and finds it doesn't do anything, because a new port setting has been added to the end and has overriden the first setting without giving any errors or warnings? Now thats a lot of "ifs". ;-). I am just curious though on what how other developers feel that these situations should be handled. -- Brian May <[EMAIL PROTECTED]>