diff options
author | Ian Jackson <ijackson@chiark.greenend.org.uk> | 2015-07-27 15:25:12 +0100 |
---|---|---|
committer | Ian Jackson <ijackson@chiark.greenend.org.uk> | 2015-07-27 15:25:12 +0100 |
commit | 9c93adb7d24891e392a1a0c3ad13ccd5fb57b6f1 (patch) | |
tree | bb8981970c7bc2c3d0aa0fb1dd63c5e5b0a94d13 /Debian | |
parent | b05ac03be1310a28f0e236b907f96103f5537f0c (diff) |
Dgit.pm: Provide executable_on_path (avoids loading File::Which which is rather more heavyweight) (no callers yet)
Diffstat (limited to 'Debian')
-rw-r--r-- | Debian/Dgit.pm | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/Debian/Dgit.pm b/Debian/Dgit.pm index a453f35..fce2ceb 100644 --- a/Debian/Dgit.pm +++ b/Debian/Dgit.pm @@ -17,7 +17,8 @@ BEGIN { @ISA = qw(Exporter); @EXPORT = qw(setup_sigwarn debiantag server_branch server_ref - stat_exists fail ensuredir waitstatusmsg failedcmd + stat_exists fail ensuredir executable_on_path + waitstatusmsg failedcmd cmdoutput cmdoutput_errok git_rev_parse git_get_ref git_for_each_ref git_for_each_tag_referring is_fast_fwd @@ -153,6 +154,17 @@ sub ensuredir ($) { die "mkdir $dir: $!"; } +sub executable_on_path ($) { + my ($program) = @_; + return 1 if $program =~ m{/}; + my @path = split /:/, ($ENV{PATH} // "/usr/local/bin:/bin:/usr/bin"); + foreach my $pe (@path) { + my $here = "$pe/$program"; + return $here if stat_exists $here && -x _; + } + return undef; +} + our @signames = split / /, $Config{sig_name}; sub waitstatusmsg () { |