texlive[44922] Master/texmf-dist/scripts/texlive/tlmgr.pl: tlmgr
commits+preining at tug.org
commits+preining at tug.org
Sun Jul 30 15:45:43 CEST 2017
Revision: 44922
http://tug.org/svn/texlive?view=revision&revision=44922
Author: preining
Date: 2017-07-30 15:45:42 +0200 (Sun, 30 Jul 2017)
Log Message:
-----------
tlmgr shell: add "set prompt" support
Modified Paths:
--------------
trunk/Master/texmf-dist/scripts/texlive/tlmgr.pl
Modified: trunk/Master/texmf-dist/scripts/texlive/tlmgr.pl
===================================================================
--- trunk/Master/texmf-dist/scripts/texlive/tlmgr.pl 2017-07-30 00:21:30 UTC (rev 44921)
+++ trunk/Master/texmf-dist/scripts/texlive/tlmgr.pl 2017-07-30 13:45:42 UTC (rev 44922)
@@ -5867,8 +5867,12 @@
#
sub action_shell {
my $protocol = 1;
- sub do_prompt {
- my $default_prompt = "tlmgr>";
+ my $default_prompt = "tlmgr>";
+ # we need to do an anonymous sub here otherwise the $default_prompt will get
+ # only fixed once and remain forever. With anonymous subs it is rebound
+ # on every call!
+ my $do_prompt;
+ $do_prompt = sub {
my $prompt = "";
my @options;
my @guarantee;
@@ -5897,7 +5901,7 @@
$did_prompt = 1;
}
}
- print "default_prompt " if (!$did_prompt);
+ print "$default_prompt " if (!$did_prompt);
my $ans = <STDIN>;
if (!defined($ans)) {
# we got Ctrl-D, just break out
@@ -5923,15 +5927,15 @@
}
if (!$isok) {
print("Please answer one of: @guarantee\n");
- return(do_prompt(@savedargs));
+ return(&$do_prompt(@savedargs));
}
}
return($ans);
- }
+ };
print "protocol $protocol\n";
while (1) {
- my $ans = do_prompt('tlmgr>');
+ my $ans = &$do_prompt($default_prompt);
return $F_OK if !defined($ans); # done if eof
my ($cmd, @args) = TeXLive::TLUtils::quotewords('\s+', 0, $ans);
@@ -5954,13 +5958,13 @@
my @valid_bool_keys
= qw/debug-translation machine-readable no-execute-actions
require-verification verify-downloads/;
- my @valid_string_keys = qw/repository/;
+ my @valid_string_keys = qw/repository prompt/;
my @valid_keys = (@valid_bool_keys, @valid_string_keys);
#
my $key = shift @args;
my $val = shift @args;
if (!$key) {
- $key = do_prompt('Choose one of...', -menu => \@valid_keys, '>');
+ $key = &$do_prompt('Choose one of...', -menu => \@valid_keys, '>');
}
if (!$key) {
print("ERROR missing key argument for get/set\n");
@@ -5972,9 +5976,11 @@
}
if ($cmd eq "set" && !defined($val)) {
if ($key eq "repository") {
- $val = do_prompt('Enter repository:');
+ $val = &$do_prompt('Enter repository:');
+ } elsif ($key eq "prompt") {
+ $val = &$do_prompt('Enter new prompt:');
} else {
- $val = do_prompt('Enter 1 for on, 0 for off:', -guarantee => [0,1]);
+ $val = &$do_prompt('Enter 1 for on, 0 for off:', -guarantee => [0,1]);
}
# deal with Ctrl-D
if (!defined($val)) {
@@ -5994,6 +6000,13 @@
}
}
print "OK\n";
+ } elsif ($key eq "prompt") {
+ if ($cmd eq "set") {
+ $default_prompt = scalar($val);
+ } else {
+ print "Current prompt: $default_prompt (but you know that, or?)\n";
+ }
+ print "OK\n";
} elsif (TeXLive::TLUtils::member($key, @valid_bool_keys)) {
if ($cmd eq "set") {
if ($val eq "0") {
@@ -6018,7 +6031,7 @@
} elsif ($cmd eq "load") {
my $what = shift @args;
if (!defined($what)) {
- $what = do_prompt("Choose...", -menu => ['local', 'remote'], '>');
+ $what = &$do_prompt("Choose...", -menu => ['local', 'remote'], '>');
}
if ($what eq "local") {
init_local_db();
@@ -8007,10 +8020,11 @@
Get the value of I<var>, or set it to I<val>. Possible I<var> names:
C<debug-translation>, C<machine-readable>, C<no-execute-actions>,
-C<require-verification>, C<verify-downloads>, and C<repository>. All
-except C<repository> are booleans, taking values 0 and 1, and behave
+C<require-verification>, C<verify-downloads>, C<repository>, and C<prompt>. All
+except C<repository> and C<prompt> are booleans, taking values 0 and 1, and behave
like the corresponding command line option. The C<repository> variable
-takes a string, and sets the remote repository location.
+takes a string, and sets the remote repository location. The C<prompt> variable
+takes a string, and sets the current default prompt.
If I<var> or then I<val> is not specified, it is prompted for.
More information about the tex-live-commits
mailing list