From e1e181875ab7334988eae52e5d7a5d1ef015587d Mon Sep 17 00:00:00 2001 From: Rudolf Polzer Date: Fri, 12 Nov 2010 10:09:48 +0100 Subject: [PATCH] add a script "cfgapply" to apply changes from one cfg to another --- misc/tools/cfgapply.pl | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 misc/tools/cfgapply.pl diff --git a/misc/tools/cfgapply.pl b/misc/tools/cfgapply.pl new file mode 100644 index 00000000..822246ab --- /dev/null +++ b/misc/tools/cfgapply.pl @@ -0,0 +1,35 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +my %cvar2line = (); +my @lines = (); + +my $first = 1; +while(<>) +{ + chomp; + s/\r//g; + + if(/^\s*(?:set\s+|seta\s+)(\S+)/) + { + if(exists $cvar2line{$1}) + { + $lines[$cvar2line{$1}] = $_; + } + else + { + $cvar2line{$1} = scalar @lines; + push @lines, $_; + } + } + elsif($first) # only take comments, empty lines from the first config + { + push @lines, $_; + } + $first = 0 + if eof; +} + +print "$_\n" for @lines; -- 2.39.2