Am 29.06.2015 um 02:11 schrieb Anand Buddhdev anandb@ripe.net:
On 29/06/15 01:07, Kahlil Hodgson wrote:
On 29 June 2015 at 07:37, John R Pierce pierce@hogranch.com wrote:
so a regex looking for "system:" vs "system {" should nicely delineate these. I dunno, I might even put that into the conversion utility and have it just quit if the file is already in the new format, and always run it.
+1 for the idempotent approach. IMHO much more robust. Also consider what will happen if someone does a 'yum downgrade' on the package or a dependency -- you might want to allow the conversion to go both ways or at least complain appropriately.
Yep. I've already considered this approach, but I avoid regexes as much as possible. They're great for some work, but they can inadvertently match too much or fail (for example if the "system" keyword and the opening brace are on different lines). You see where I'm going? But, this is a digression...
that is exactly what regex can do for you. it confirms the "language" of the config file, unattached from new lines or space characters. Sure, the expression itself is more "complicated" ... (a combination of tools is also possible eg. tr, awk, sed, grep)
-- LF