]> andersk Git - openssh.git/blame_incremental - fixpaths
- (stevesk) logintest.c: fix for systems without __progname
[openssh.git] / fixpaths
... / ...
CommitLineData
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
10if (!defined(@ARGV)) { die ("$usage"); }
11
12# read in the command line and get some definitions
13while ($_=$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 @cmd = split(//, $ARGV[0]); $opt = $cmd[1];
26 die ("$usage$0: unknown option '-$opt'\n");
27 }
28} # while parsing arguments
29
30if (!defined(%def)) {
31 die ("$0: nothing to do - no substitutions listed!\n");
32}
33
34for $f (@ARGV) {
35
36 $f =~ /(.*\/)*(.*)$/;
37 $of = $2.".$ext";
38
39 open(IN, "<$f") || die ("$0: input file $f missing!\n");
40 open(OUT, ">$of") || die ("$0: cannot create output file $of: $!\n");
41 while (<IN>) {
42 for $s (keys(%def)) {
43 s#$s#$def{$s}#;
44 } # for $s
45 print OUT;
46 } # while <IN>
47} # for $f
48
49exit 0;
This page took 0.032686 seconds and 5 git commands to generate.