From 60b42ef1e1d7036f8dfe08a7e66f824c26a659fb Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Sat, 15 Apr 2017 00:14:53 +0000 Subject: support forced arguments in standard prompts, no bold git-svn-id: svn://tug.org/texlive/trunk@43802 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/scripts/texlive/tlmgr.pl | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) (limited to 'Master') diff --git a/Master/texmf-dist/scripts/texlive/tlmgr.pl b/Master/texmf-dist/scripts/texlive/tlmgr.pl index 4318029d48a..dfb6811ebfa 100755 --- a/Master/texmf-dist/scripts/texlive/tlmgr.pl +++ b/Master/texmf-dist/scripts/texlive/tlmgr.pl @@ -6504,12 +6504,11 @@ sub check_on_writable { # tlmgr shell code sub action_shell { my $protocol = 1; + our $promptfunc; eval { require IO::Prompter; }; - - our $promptfunc; if ($@) { printf STDERR "Cannot find IO::Prompter module, reduced interactive functionality!\n"; $promptfunc = sub { @@ -6517,6 +6516,7 @@ sub action_shell { my $prompt = ""; my @options; my @guarantee; + my @savedargs = @_; while (defined(my $arg = shift @_)) { if ($arg =~ m/^-prompt$/) { $prompt .= shift @_; @@ -6541,9 +6541,23 @@ sub action_shell { print "(", join(",", @options), ") "; } my $ans = ; + if (!defined($ans)) { + # we got Ctrl-D, just break out + return; + } chomp($ans); if (@guarantee) { - # TODO TODO TODO + my $isok = 0; + for my $g (@guarantee) { + if ($ans eq $g) { + $isok = 1; + last; + } + } + if (!$isok) { + print("Please answer one of @guarantee!\n"); + return($promptfunc->(@savedargs)); + } } return($ans); } @@ -6560,10 +6574,11 @@ sub action_shell { while (1) { # print $prompt; # my $ans = ; - my $ans = do_prompt('tlmgr>', -style => 'bold'); + my $ans = do_prompt('tlmgr>'); # chomp $ans; + next if (!defined($ans)); my ($cmd, @args) = TeXLive::TLUtils::quotewords('\s+', 0, $ans); - next if (!$cmd); + next if (!defined($cmd)); if ($cmd eq "protocol") { print "protocol $protocol\n"; } elsif ($cmd eq "version") { @@ -6595,6 +6610,9 @@ sub action_shell { $val = do_prompt('Enter 1 for on, 0 for off:', -guarantee => [0,1]); } } + # deal with Ctrl-D + next if (!defined($val)); + if ($key eq "repository") { if ($cmd eq "set") { $location = scalar($val); -- cgit v1.2.3