From e28b3c396eae6604cfe3edad0b3b989928b15d03 Mon Sep 17 00:00:00 2001 From: Marius Gavrilescu Date: Sat, 7 Jan 2017 18:18:28 +0200 Subject: [PATCH] Prevent warnings on systems without $ENV{HOME} / $ENV{USER} --- lastmsg | 5 ++++- lib/App/Lastmsg.pm | 7 +++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/lastmsg b/lastmsg index 7f818b7..65b4786 100755 --- a/lastmsg +++ b/lastmsg @@ -65,7 +65,10 @@ string or a list of strings). The C field of these emails is scanned. If not provided, it defaults to F and -F<$ENV{HOME}/Maildir/>. +F<$ENV{HOME}/Maildir/>. If USER or HOME are not in the environment, +the corresponding default directory is ignored. So on a system with +neither of these variables defined, this option will default to an +empty list. B See L for information on how the type of a folder is identified. In short, the suffix of the folder is analyzed: diff --git a/lib/App/Lastmsg.pm b/lib/App/Lastmsg.pm index 0addd51..a5a27b5 100644 --- a/lib/App/Lastmsg.pm +++ b/lib/App/Lastmsg.pm @@ -14,10 +14,9 @@ use POSIX qw/strftime/; our $OUTPUT_FILEHANDLE = \*STDOUT; our $VERSION = '0.001002'; -our @DEFAULT_INBOX = ( - "/var/mail/$ENV{USER}", - "$ENV{HOME}/Maildir/", -); +our @DEFAULT_INBOX; +push @DEFAULT_INBOX, "/var/mail/$ENV{USER}" if exists $ENV{USER}; +push @DEFAULT_INBOX, "$ENV{HOME}/Maildir" if exists $ENV{HOME}; sub run { my $config = Config::Auto->new(format => 'yaml')->parse; -- 2.30.2