From: Marius Gavrilescu Date: Sat, 7 Jan 2017 16:18:28 +0000 (+0200) Subject: Prevent warnings on systems without $ENV{HOME} / $ENV{USER} X-Git-Tag: 0.002~4 X-Git-Url: http://git.ieval.ro/?p=app-lastmsg.git;a=commitdiff_plain;h=e28b3c396eae6604cfe3edad0b3b989928b15d03 Prevent warnings on systems without $ENV{HOME} / $ENV{USER} --- 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;