From 64cd678ebe9205b9b58763366ebfe520dccade48 Mon Sep 17 00:00:00 2001 From: Michael Mikonos <127171689+mknos@users.noreply.github.com> Date: Wed, 12 Jun 2024 17:03:55 +0800 Subject: [PATCH] whoami: factor conditional * Make code even simpler by splitting USER and USERNAME checks into their own subsequent closures * Tested this by commenting the other subs and running 'perl env -i USERNAME=bob perl whoami' --- bin/whoami | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bin/whoami b/bin/whoami index add4eb2a..dc953127 100644 --- a/bin/whoami +++ b/bin/whoami @@ -26,7 +26,8 @@ my @coderefs = ( sub { getpwuid($>) }, sub { require Win32; Win32::LoginName() }, sub { getlogin }, - sub { defined $ENV{USER} ? $ENV{USER} : $ENV{USERNAME} }, + sub { $ENV{'USER'} }, + sub { $ENV{'USERNAME'} }, ); foreach my $coderef ( @coderefs ) {