From: Rudolf Polzer Date: Fri, 12 Nov 2010 09:09:48 +0000 (+0100) Subject: add a script "cfgapply" to apply changes from one cfg to another X-Git-Tag: xonotic-v0.1.0preview~66 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=e1e181875ab7334988eae52e5d7a5d1ef015587d;p=xonotic%2Fxonotic.git add a script "cfgapply" to apply changes from one cfg to another --- 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;