]> git.rm.cloudns.org Git - xonotic/xonotic.git/commitdiff
add a script "cfgapply" to apply changes from one cfg to another
authorRudolf Polzer <divVerent@xonotic.org>
Fri, 12 Nov 2010 09:09:48 +0000 (10:09 +0100)
committerRudolf Polzer <divVerent@xonotic.org>
Fri, 12 Nov 2010 09:09:48 +0000 (10:09 +0100)
misc/tools/cfgapply.pl [new file with mode: 0644]

diff --git a/misc/tools/cfgapply.pl b/misc/tools/cfgapply.pl
new file mode 100644 (file)
index 0000000..822246a
--- /dev/null
@@ -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;