X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=dgit.git;a=blobdiff_plain;f=Debian%2FDgit.pm;h=fce2ceb68ed7ef2eefdec0dec170a53c22632f99;hp=a453f352718b33a5567e040cdd9302973c40b279;hb=9c93adb7d24891e392a1a0c3ad13ccd5fb57b6f1;hpb=05532651f81d706de1fab66e8ebe97b9f646b1f9 diff --git a/Debian/Dgit.pm b/Debian/Dgit.pm index a453f352..fce2ceb6 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 () {