]> andersk Git - openssh.git/blob - fixpaths
- Big manpage and config file cleanup from Andre Lucas
[openssh.git] / fixpaths
1 #!/usr/bin/perl -w
2 #
3 # fixpaths  - substitute makefile variables into text files
4
5
6 $usage = "Usage: $0 [-x<file dot-suffix>] [-Dstring=replacement] [[infile] ...]\n";
7
8 $ext="out";
9
10 if (!defined(@ARGV)) { die ("$usage"); }
11
12 # read in the command line and get some definitions
13 while ($_=$ARGV[0], /^-/) {
14   if (/^-[Dx]/) {
15     # definition
16     shift(@ARGV);
17     if ( /-D(.*)=(.*)/ ) {
18       $def{"$1"}=$2;
19     } elsif ( /-x\s*(\w+)/ ) {
20         $ext=$1;
21     } else {
22       die ("$usage$0: error in command line arguments.\n");
23     }
24   } else {
25     die ("$usage$0: unknown option '-".$ARGV[0][1]."'\n");
26   }
27 } # while parsing arguments
28
29 if (!defined(%def)) {
30   die ("$0: nothing to do - no substitutions listed!\n");
31 }
32
33 for $f (@ARGV) {
34
35   $f =~ /(.*\/)*(.*)$/;
36   $of = $2.".$ext"; 
37
38   open(IN, "<$f")          || die ("$0: input file $f missing!\n");
39   if (open(OUT, ">$of")) {
40     while (<IN>) {
41       for $s (keys(%def)) {
42         s#$s#$def{$s}#;
43       } # for $s
44       print OUT;
45     } # while <IN>
46   } # if (outfile open)
47 } # for $f
48
49 exit 0;
This page took 0.72648 seconds and 5 git commands to generate.