summaryrefslogtreecommitdiff
path: root/fixpaths
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>1999-12-27 09:23:58 +1100
committerDamien Miller <djm@mindrot.org>1999-12-27 09:23:58 +1100
commitc0d739039807abaa7985112370b4c5f4e85e02d7 (patch)
tree70d1579e28003ac341dfa9330d6e1d63e8108bc2 /fixpaths
parentaae1093640162022abba350d94c3051e6d730425 (diff)
- Automatically correct paths in manpages and configuration files. Patch
and script from Andre Lucas <andre.lucas@dial.pipex.com> - Removed credits from README to CREDITS file, updated.
Diffstat (limited to 'fixpaths')
-rwxr-xr-xfixpaths47
1 files changed, 47 insertions, 0 deletions
diff --git a/fixpaths b/fixpaths
new file mode 100755
index 000000000..6a2a3a0b3
--- /dev/null
+++ b/fixpaths
@@ -0,0 +1,47 @@
1#!/usr/bin/perl -w
2#
3# fixpaths - substitute makefile variables into text files
4
5
6$usage = "Usage: $0 [-D<variable>=<value>] [[infile] ...]\n";
7
8if (!defined(@ARGV)) { die ("$usage"); }
9
10# read in the command line and get some definitions
11while ($_=$ARGV[0], /^-/) {
12 if (/^-D/) {
13 # definition
14 shift(@ARGV);
15 if ( /-D(.*)=(.*)/ ) {
16 $def{"$1"}=$2;
17 } else {
18 die ("$usage$0: error in command line arguments.\n");
19 }
20 } else {
21 &usage; die ("$usage$0: unknown option '-".$ARGV[0][1]."'\n");
22 }
23} # while parsing arguments
24
25if (!defined(%def)) {
26 die ("$0: nothing to do - no substitutions listed!\n");
27}
28
29for $f (@ARGV) {
30
31 $f =~ /(.*\/)*(.*)$/;
32 $of = $2; $of =~ s/.in$//;
33
34 print("Making substitutions for $of\n");
35
36 open(IN, "<$f") || die ("$0: input file $f missing!\n");
37 if (open(OUT, ">$of")) {
38 while (<IN>) {
39 for $s (keys(%def)) {
40 s#\@$s\@#$def{$s}#;
41 } # for $s
42 print OUT;
43 } # while <IN>
44 } # if (outfile open)
45} # for $f
46
47exit 0;