Prevent warnings on systems without $ENV{HOME} / $ENV{USER}
authorMarius Gavrilescu <marius@ieval.ro>
Sat, 7 Jan 2017 16:18:28 +0000 (18:18 +0200)
committerMarius Gavrilescu <marius@ieval.ro>
Sat, 7 Jan 2017 16:18:28 +0000 (18:18 +0200)
lastmsg
lib/App/Lastmsg.pm

diff --git a/lastmsg b/lastmsg
index 7f818b77f0c90fb198c316ad8f05684ce5327475..65b47861db412574a42b116bf90a7e0c3011bff6 100755 (executable)
--- a/lastmsg
+++ b/lastmsg
@@ -65,7 +65,10 @@ string or a list of strings). The C<From> field of these emails is
 scanned.
 
 If not provided, it defaults to F</var/mail/$ENV{USER}> 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<NOTE:> See L<Email::FolderType> for information on how the type of a
 folder is identified. In short, the suffix of the folder is analyzed:
index 0addd51d779a3643630b7c1cc24dd5b70436b425..a5a27b59c42af9fea88cebcfee4c86d870469561 100644 (file)
@@ -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;
This page took 0.010998 seconds and 4 git commands to generate.