diff options
author | Norbert Preining <preining@logic.at> | 2017-04-18 23:55:09 +0000 |
---|---|---|
committer | Norbert Preining <preining@logic.at> | 2017-04-18 23:55:09 +0000 |
commit | 94947fe94fec2495af218a277690b138898b3162 (patch) | |
tree | 4577baa448dbf6a8992ec701cf101a950e192152 /Master | |
parent | 40b4b6e177c62a14c166dbba6adf3abc415af4b2 (diff) |
get rid of IO::Prompter optional dep, implement asking myself
git-svn-id: svn://tug.org/texlive/trunk@43915 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master')
-rwxr-xr-x | Master/texmf-dist/scripts/texlive/tlmgr.pl | 111 |
1 files changed, 54 insertions, 57 deletions
diff --git a/Master/texmf-dist/scripts/texlive/tlmgr.pl b/Master/texmf-dist/scripts/texlive/tlmgr.pl index 96cbb3b6cc1..6fda5f917ab 100755 --- a/Master/texmf-dist/scripts/texlive/tlmgr.pl +++ b/Master/texmf-dist/scripts/texlive/tlmgr.pl @@ -6504,70 +6504,67 @@ sub check_on_writable { # tlmgr shell code sub action_shell { my $protocol = 1; - our $promptfunc; - - eval { - require IO::Prompter; - }; - if ($@) { - printf STDERR "Cannot find IO::Prompter module, reduced interactive functionality!\n"; - $promptfunc = sub { - my $default_prompt = "tlmgr>"; - my $prompt = ""; - my @options; - my @guarantee; - my @savedargs = @_; - while (defined(my $arg = shift @_)) { - if ($arg =~ m/^-prompt$/) { - $prompt .= shift @_; - } elsif ($arg =~ m/^-style$/) { - # ignore style here - shift @_; - } elsif ($arg =~ m/^-menu$/) { - my $options = shift @_; - @options = @$options; - } elsif ($arg =~ m/^-guarantee$/) { - my $guarantee = shift @_; - @guarantee = @$guarantee; - } elsif ($arg =~ m/^-/) { - print "ERROR unsupported prompt command, please report: $arg!\n"; - } else { - $prompt .= $arg; + sub do_prompt { + my $default_prompt = "tlmgr>"; + my $prompt = ""; + my @options; + my @guarantee; + my @savedargs = @_; + my $did_prompt = 0; + while (defined(my $arg = shift @_)) { + if ($arg =~ m/^-prompt$/) { + print shift @_, " "; + $did_prompt = 1; + } elsif ($arg =~ m/^-menu$/) { + my $options = shift @_; + @options = @$options; + print "\n"; + my $c = 1; + for my $o (@options) { + print " $c) $o\n"; + $c++; } + } elsif ($arg =~ m/^-guarantee$/) { + my $guarantee = shift @_; + @guarantee = @$guarantee; + } elsif ($arg =~ m/^-/) { + print "ERROR unsupported prompt command, please report: $arg!\n"; + } else { + print $arg, " "; + $did_prompt = 1; } - $prompt = ($prompt ? $prompt : $default_prompt ); - print "$prompt "; - if (@options) { - print "(", join(",", @options), ") "; - } - my $ans = <STDIN>; - if (!defined($ans)) { - # we got Ctrl-D, just break out + } + print "default_prompt " if (!$did_prompt); + my $ans = <STDIN>; + if (!defined($ans)) { + # we got Ctrl-D, just break out + return; + } + chomp($ans); + if (@options) { + $ans--; + if ($ans >= 0 && $ans < $#options) { + $ans = $options[$ans]; + return($ans); + } else { + print "ERROR invalid answer\n"; return; } - chomp($ans); - if (@guarantee) { - 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)); + } + if (@guarantee) { + my $isok = 0; + for my $g (@guarantee) { + if ($ans eq $g) { + $isok = 1; + last; } } - return($ans); + if (!$isok) { + print("Please answer one of @guarantee!\n"); + return(do_prompt(@savedargs)); + } } - } else { - $promptfunc = \&IO::Prompter::prompt; - } - sub do_prompt { - our $promptfunc; - my $foo = $promptfunc->(@_); - return($foo); + return($ans); } print "protocol $protocol\n"; |