diff options
author | Adam Spiers <stow@adamspiers.org> | 2019-06-28 00:41:55 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-28 00:41:55 +0100 |
commit | 5f875009f80cfd309223378bfcdb1d4d85599079 (patch) | |
tree | 625c662781d8fc9e5f0422543431c0834b0ec0ea | |
parent | fea63ffe6500f2722999761c000fabec14164297 (diff) | |
parent | b42cb89fddf34882faabb7d6abcac256308faca1 (diff) | |
download | stow-5f875009f80cfd309223378bfcdb1d4d85599079.tar.gz |
Avoid dereferencing $ENV{HOME} if it is undefined (#32)
Avoid dereferencing $ENV{HOME} if it is undefined
-rwxr-xr-x | bin/stow.in | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/bin/stow.in b/bin/stow.in index 84dfbd2..e33a4a6 100755 --- a/bin/stow.in +++ b/bin/stow.in @@ -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"; |