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