summaryrefslogtreecommitdiff
path: root/perl5
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2020-01-27 13:01:50 -0700
committerSean Whitton <spwhitton@spwhitton.name>2020-01-27 13:03:19 -0700
commitec71172cbb11466f442a8f0b811c14ff59cd7782 (patch)
treee5f2a959fb916d2b6561071e10996e611daf2385 /perl5
parentd873a7f42d0a50404cc973079275591ccd5cd028 (diff)
downloaddotfiles-ec71172cbb11466f442a8f0b811c14ff59cd7782.tar.gz
refactor as_me
Diffstat (limited to 'perl5')
-rw-r--r--perl5/Local/Rex/Util.pm11
1 files changed, 8 insertions, 3 deletions
diff --git a/perl5/Local/Rex/Util.pm b/perl5/Local/Rex/Util.pm
index 003707c1..db81c8d8 100644
--- a/perl5/Local/Rex/Util.pm
+++ b/perl5/Local/Rex/Util.pm
@@ -7,12 +7,17 @@ use parent 'Exporter';
use Rex -feature => ['1.4'];
-our @EXPORT = qw( as_me );
+our @EXPORT = qw( as as_me );
+
+sub as ($&) {
+ can_run "sudo" or die "wanted to execute as $_[0] but no sudo on PATH!";
+ sudo { user => $_[0], command => $_[1]};
+}
sub as_me (&) {
+ sub as ($&);
my $me = get("me") || "spwhitton";
- can_run "sudo" or die "wanted to execute as $me but no sudo on PATH!";
- sudo { user => $me, command => $_[0] };
+ as $me, \&{$_[0]};
}
1;