diff options
Diffstat (limited to 'Master/tlpkg/installer/install-menu-text.pl')
-rwxr-xr-x | Master/tlpkg/installer/install-menu-text.pl | 62 |
1 files changed, 36 insertions, 26 deletions
diff --git a/Master/tlpkg/installer/install-menu-text.pl b/Master/tlpkg/installer/install-menu-text.pl index 68fc8071d8f..86e8fd32de7 100755 --- a/Master/tlpkg/installer/install-menu-text.pl +++ b/Master/tlpkg/installer/install-menu-text.pl @@ -432,7 +432,7 @@ sub language_menu { } } - + sub directories_menu { my %command=( 'self' => \&directories_menu, @@ -476,63 +476,53 @@ EOF print " Note: ~ will expand to \$HOME (or to %USERPROFILE% on Windows)\n"; } - other_options qw (R Q); + other_options qw(R Q); my $answer = prompt 'Enter command'; + my $dir; + my $home = getenv('HOME'); $home = getenv('USERPROFILE') if (win32); $home ||= '~'; if ("\u$answer" eq '1') { print "New value for $maindir [$vars{$maindir}]: "; - chomp($answer=<STDIN>); - $vars{$maindir}="$answer" if (length $answer); - $vars{$maindir}=~s@\\@/@g if (win32); - $vars{$maindir} =~ s/^~/$home/; + $answer = &input_dirname (); + $vars{$maindir} = $answer if $answer ne ""; if ($vars{$maindir}=~/^(.*)\/$texlive_release$/) { $vars{'TEXMFLOCAL'}="$1/texmf-local"; $vars{'TEXMFSYSVAR'}="$1/$texlive_release/texmf-var"; $vars{'TEXMFSYSCONFIG'}="$1/$texlive_release/texmf-config"; - $vars{'TEXDIRW'} = $vars{'TEXDIR'} unless $vars{'from_dvd'}; - return $command{'self'}; } elsif ($vars{$maindir}=~/^(.*)$/) { $vars{'TEXMFLOCAL'}="$1/texmf-local"; $vars{'TEXMFSYSVAR'}="$1/texmf-var"; $vars{'TEXMFSYSCONFIG'}="$1/texmf-config"; - $vars{'TEXDIRW'} = $vars{'TEXDIR'} unless $vars{'from_dvd'}; - return $command{'self'}; } + $vars{'TEXDIRW'} = $vars{'TEXDIR'} unless $vars{'from_dvd'}; + return $command{'self'}; } elsif ("\u$answer" eq '2') { print "New value for TEXMFLOCAL [$vars{'TEXMFLOCAL'}]: "; - chomp($answer=<STDIN>); - $vars{'TEXMFLOCAL'}="$answer" if (length $answer); - $vars{'TEXMFLOCAL'}=~s@\\@/@g if (win32); - $vars{'TEXMFLOCAL'} =~ s/^~/$home/; + $answer = &input_dirname (); + $vars{'TEXMFLOCAL'} = $answer if $answer ne ""; return $command{'self'}; } elsif ("\u$answer" eq '3') { print "New value for TEXMFSYSVAR [$vars{'TEXMFSYSVAR'}]: "; - chomp($answer=<STDIN>); - $vars{'TEXMFSYSVAR'}="$answer" if (length $answer); - $vars{'TEXMFSYSVAR'}=~s@\\@/@g if (win32); - $vars{'TEXMFSYSVAR'} =~ s/^~/$home/; + $answer = &input_dirname (); + $vars{'TEXMFSYSVAR'} = $answer if $answer ne ""; return $command{'self'}; } elsif ("\u$answer" eq '4') { print "New value for TEXMFSYSCONFIG [$vars{'TEXMFSYSCONFIG'}]: "; - chomp($answer=<STDIN>); - $vars{'TEXMFSYSCONFIG'}="$answer" if (length $answer); - $vars{'TEXMFSYSCONFIG'}=~s@\\@/@g if (win32); - $vars{'TEXMFSYSCONFIG'} =~ s/^~/$home/; + $answer = &input_dirname (); + $vars{'TEXMFSYSCONFIG'} = $answer if $answer ne ""; return $command{'self'}; } elsif ("\u$answer" eq '5') { print "New value for TEXMFHOME [$vars{'TEXMFHOME'}]: "; - chomp($answer=<STDIN>); - $vars{'TEXMFHOME'}="$answer" if (length $answer); - $vars{'TEXMFHOME'}=~s@\\@/@g if (win32); + $answer = &input_dirname (); + $vars{'TEXMFHOME'} = $answer if $answer ne ""; return $command{'self'}; - } if (defined $command{"\u$answer"}) { @@ -543,6 +533,26 @@ EOF } } + +# Helper function to read a directory name and clean it up. +# +sub input_dirname +{ + chomp (my $answer = <STDIN>); + return "" if $answer eq ""; + + $answer =~ s!\\!/!g if win32(); # switch to forward slashes + $answer =~ s/^~/$home/; # $home expansion + + # relative paths are unlikely to work in texmf.cnf, et al., + # and don't have any apparent practical use. Convert to absolute. + if (! File::Spec->file_name_is_absolute($answer)) { + $answer = Cwd::abs_path($answer); + } + return $answer; +} + + $vars{'page'}=0; sub html2text { |