diff options
author | Norbert Preining <preining@logic.at> | 2017-07-30 13:45:42 +0000 |
---|---|---|
committer | Norbert Preining <preining@logic.at> | 2017-07-30 13:45:42 +0000 |
commit | 5c0a56c4f3997da8fe08cba8343cf23e7ccf6899 (patch) | |
tree | 126544b702d36e98dd5b5011ae2377bfff4534e7 /Master/texmf-dist | |
parent | 4bcfa788c1e64cea86de4bce619638ac71e86abd (diff) |
tlmgr shell: add "set prompt" support
git-svn-id: svn://tug.org/texlive/trunk@44922 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist')
-rwxr-xr-x | Master/texmf-dist/scripts/texlive/tlmgr.pl | 42 |
1 files changed, 28 insertions, 14 deletions
diff --git a/Master/texmf-dist/scripts/texlive/tlmgr.pl b/Master/texmf-dist/scripts/texlive/tlmgr.pl index 59fad25caf1..8c0a171bf29 100755 --- a/Master/texmf-dist/scripts/texlive/tlmgr.pl +++ b/Master/texmf-dist/scripts/texlive/tlmgr.pl @@ -5867,8 +5867,12 @@ sub action_key { # 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 @@ sub action_shell { $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 @@ sub action_shell { } 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 @@ sub action_shell { 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 @@ sub action_shell { } 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 @@ sub action_shell { } } 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 @@ sub action_shell { } 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 @@ Save the local TLPDB, presumably after other operations have changed it. 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. |