diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2022-02-27 15:32:01 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2022-02-27 15:32:58 -0700 |
commit | 26420cbb7572b07becbe24ef0f27c91aa088850e (patch) | |
tree | c2cc53e37165bfbeb7f363638acb6ffdcf22e2e1 /perl5 | |
parent | 1017c62a2d4b1761807c75f3d1134516389d897d (diff) | |
download | dotfiles-26420cbb7572b07becbe24ef0f27c91aa088850e.tar.gz |
locmaint --sys: check that aptitude is on PATH
Diffstat (limited to 'perl5')
-rw-r--r-- | perl5/Local/Util.pm | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/perl5/Local/Util.pm b/perl5/Local/Util.pm index a9d3d13f..edba6d07 100644 --- a/perl5/Local/Util.pm +++ b/perl5/Local/Util.pm @@ -20,7 +20,7 @@ use warnings; use Exporter 'import'; -our @EXPORT_OK = qw(as_root); +our @EXPORT_OK = qw(as_root executable_find); # Prefix a command if that's necessary to run it as root. Currently # supports only sudo(1). If passed more than one argument, prepends @@ -47,4 +47,15 @@ sub as_root { } } +=head executable_find($name) + +Return the full path to $name if it is on PATH, else error. + +=cut + +sub executable_find { + chomp(my $output = `sh -c "command -v $_[0]"`); + $? == 0 ? return $output : die "$_[0] not found on PATH" +} + 1; |