Avoid dereferencing $ENV{HOME} if it is undefined (#32)

Avoid dereferencing $ENV{HOME} if it is undefined
This commit is contained in:
Adam Spiers 2019-06-28 00:41:55 +01:00 committed by GitHub
commit 5f875009f8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -662,7 +662,11 @@ sub check_packages {
#=============================================================================
sub get_config_file_options {
my @defaults = ();
for my $file ("$ENV{HOME}/.stowrc", '.stowrc') {
my @dirlist = ('.stowrc');
if (defined($ENV{HOME})) {
unshift(@dirlist, "$ENV{HOME}/.stowrc");
}
for my $file (@dirlist) {
if (-r $file) {
open my $FILE, '<', $file
or die "Could not open $file for reading\n";