summaryrefslogtreecommitdiffstats
path: root/src/windows/build/which.pl
diff options
context:
space:
mode:
authorKevin Koch <kpkoch@mit.edu>2007-03-05 14:07:07 +0000
committerKevin Koch <kpkoch@mit.edu>2007-03-05 14:07:07 +0000
commitc5c0e39a4591077e9eb9b7a55243886476ebabaf (patch)
tree867b7a974a038dee2011fb088bac1c7e99d6eb27 /src/windows/build/which.pl
parentd47811aa8c5314097b28c49a47020670f8743133 (diff)
downloadkrb5-c5c0e39a4591077e9eb9b7a55243886476ebabaf.tar.gz
krb5-c5c0e39a4591077e9eb9b7a55243886476ebabaf.tar.xz
krb5-c5c0e39a4591077e9eb9b7a55243886476ebabaf.zip
Automation for building KfW
Target_Version: 1.6.1 Component: KfW git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@19205 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/windows/build/which.pl')
-rw-r--r--src/windows/build/which.pl69
1 files changed, 69 insertions, 0 deletions
diff --git a/src/windows/build/which.pl b/src/windows/build/which.pl
new file mode 100644
index 000000000..1cf89ce57
--- /dev/null
+++ b/src/windows/build/which.pl
@@ -0,0 +1,69 @@
+#!perl -w
+
+use strict;
+use Config;
+use File::Basename;
+use Getopt::Long;
+
+$0 = fileparse($0);
+
+sub main
+{
+ Getopt::Long::Configure('bundling', 'no_auto_abbrev',
+ 'no_getopt_compat', 'require_order',
+ 'ignore_case', 'pass_through',
+ 'prefix_pattern=(--|-|\+|\/)',
+ );
+ my $OPT = {};
+ GetOptions($OPT,
+ 'help|h|?',
+ 'all|a',
+ 'quiet|q',
+ 'debug|d',
+ 'path:s',
+ );
+
+ my $f = shift @ARGV;
+ if ($OPT->{help} || !$f) {
+ usage();
+ exit(0) if $OPT->{help};
+ exit(1);
+ }
+
+ my $p = $OPT->{path} || $ENV{PATH};
+ my $s = $Config{path_sep};
+ my @d = split(/$s/, $p);
+ my @e = split(/$s/, lc($ENV{PATHEXT} || '.bat;.exe;.com'));
+ my @f = ($f, map { $f.$_; } @e);
+ my $found = 0;
+ foreach my $d (@d) {
+ print "(Searching $d)\n" if $OPT->{debug};
+ foreach my $f (@f) {
+ my $df = $d.'\\'.$f; # cannot use $File::Spec->catfile due to UNC.
+ print "(Checking for $df)\n" if $OPT->{debug};
+ if (-f $df) {
+ exit(0) if $OPT->{quiet};
+ print "$df\n";
+ exit(0) if !$OPT->{all};
+ $found = 1;
+ }
+ }
+ }
+ print "Could not find $f\n" if !$found && !$OPT->{quiet};
+ exit($found?0:1);
+}
+
+sub usage
+{
+ print <<USAGE;
+Usage: $0 [options] command
+ command find file executed by this command by looking at PATH
+ -d, --debug debug output
+ -a, --all find all such commands in PATH
+ -q, --quiet no output, exit with non-zero errorcode if not found
+ --path PATHARG search PATHARG instead of the PATH environment variable
+ -?, -H, --help help
+USAGE
+}
+
+main();