xref: /minix3/crypto/external/bsd/openssl/dist/util/perlpath.pl (revision ebfedea0ce5bbe81e252ddf32d732e40fb633fae)
1*ebfedea0SLionel Sambuc#!/usr/local/bin/perl
2*ebfedea0SLionel Sambuc#
3*ebfedea0SLionel Sambuc# modify the '#!/usr/local/bin/perl'
4*ebfedea0SLionel Sambuc# line in all scripts that rely on perl.
5*ebfedea0SLionel Sambuc#
6*ebfedea0SLionel Sambuc
7*ebfedea0SLionel Sambucrequire "find.pl";
8*ebfedea0SLionel Sambuc
9*ebfedea0SLionel Sambuc$#ARGV == 0 || print STDERR "usage: perlpath newpath  (eg /usr/bin)\n";
10*ebfedea0SLionel Sambuc&find(".");
11*ebfedea0SLionel Sambuc
12*ebfedea0SLionel Sambucsub wanted
13*ebfedea0SLionel Sambuc	{
14*ebfedea0SLionel Sambuc	return unless /\.pl$/ || /^[Cc]onfigur/;
15*ebfedea0SLionel Sambuc
16*ebfedea0SLionel Sambuc	open(IN,"<$_") || die "unable to open $dir/$_:$!\n";
17*ebfedea0SLionel Sambuc	@a=<IN>;
18*ebfedea0SLionel Sambuc	close(IN);
19*ebfedea0SLionel Sambuc
20*ebfedea0SLionel Sambuc	if (-d $ARGV[0]) {
21*ebfedea0SLionel Sambuc		$a[0]="#!$ARGV[0]/perl\n";
22*ebfedea0SLionel Sambuc	}
23*ebfedea0SLionel Sambuc	else {
24*ebfedea0SLionel Sambuc		$a[0]="#!$ARGV[0]\n";
25*ebfedea0SLionel Sambuc	}
26*ebfedea0SLionel Sambuc
27*ebfedea0SLionel Sambuc	# Playing it safe...
28*ebfedea0SLionel Sambuc	$new="$_.new";
29*ebfedea0SLionel Sambuc	open(OUT,">$new") || die "unable to open $dir/$new:$!\n";
30*ebfedea0SLionel Sambuc	print OUT @a;
31*ebfedea0SLionel Sambuc	close(OUT);
32*ebfedea0SLionel Sambuc
33*ebfedea0SLionel Sambuc	rename($new,$_) || die "unable to rename $dir/$new:$!\n";
34*ebfedea0SLionel Sambuc	chmod(0755,$_) || die "unable to chmod $dir/$new:$!\n";
35*ebfedea0SLionel Sambuc	}
36