]> andersk Git - openssh.git/blob - fixpaths
- Automatically correct paths in manpages and configuration files. Patch
[openssh.git] / fixpaths
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;
This page took 0.74554 seconds and 5 git commands to generate.