diff options
Diffstat (limited to 'Master/tlpkg/TeXLive/TLUtils.pm')
-rw-r--r-- | Master/tlpkg/TeXLive/TLUtils.pm | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/Master/tlpkg/TeXLive/TLUtils.pm b/Master/tlpkg/TeXLive/TLUtils.pm index da229c052a0..7a6936645db 100644 --- a/Master/tlpkg/TeXLive/TLUtils.pm +++ b/Master/tlpkg/TeXLive/TLUtils.pm @@ -277,9 +277,6 @@ $::opt_verbosity = 0; # see process_logging_options our $SshURIRegex = '^((ssh|scp)://([^@]*)@([^/]*)/|([^@]*)@([^:]*):).*$'; -# only search for home directory once, and save expansion here -my $user_home_dir; - =head2 Platform detection =over 4 @@ -897,21 +894,23 @@ sub diskfree { Returns the current user's home directory (C<$HOME> on Unix, C<$USERPROFILE> on Windows, and C<~> if none of the two are -set. +set. Save in package variable C<$user_home_dir> after computing. =cut +# only search for home directory once, and save expansion here +my $user_home_dir; + sub get_user_home { return $user_home_dir if ($user_home_dir); - $user_home_dir = getenv('HOME'); - $user_home_dir = getenv('USERPROFILE') if win32(); - $user_home_dir ||= '~'; - return($user_home_dir); + $user_home_dir = getenv (win32() ? 'USERPROFILE' : 'HOME') || '~'; + return $user_home_dir; } =item C<expand_tilde($str)> -Expands initial C<~> with the user's home directory in C<$str>. +Expands initial C<~> with the user's home directory in C<$str> if +available, else leave C<~> in place. =cut @@ -919,7 +918,7 @@ sub expand_tilde { my $str = shift; my $h = get_user_home(); $str =~ s/^~/$h/; - return($str); + return $str; } =back |