diff options
author | Damien Miller <djm@mindrot.org> | 1999-12-27 09:23:58 +1100 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 1999-12-27 09:23:58 +1100 |
commit | c0d739039807abaa7985112370b4c5f4e85e02d7 (patch) | |
tree | 70d1579e28003ac341dfa9330d6e1d63e8108bc2 /fixpaths | |
parent | aae1093640162022abba350d94c3051e6d730425 (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-x | fixpaths | 47 |
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 | |||
8 | if (!defined(@ARGV)) { die ("$usage"); } | ||
9 | |||
10 | # read in the command line and get some definitions | ||
11 | while ($_=$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 | |||
25 | if (!defined(%def)) { | ||
26 | die ("$0: nothing to do - no substitutions listed!\n"); | ||
27 | } | ||
28 | |||
29 | for $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 | |||
47 | exit 0; | ||