diff options
author | Karl Berry <karl@freefriends.org> | 2017-05-04 17:31:52 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2017-05-04 17:31:52 +0000 |
commit | 5577fbe4bdb23bb33f1a36a7867a8a733a399c8e (patch) | |
tree | d0d26f42c1264b8b754946b00d8727d2fb59a4c4 /Master/texmf-dist/scripts | |
parent | b20a0b4a6f703f6ecfe28a6527be52cc8682148d (diff) |
(do_prompt): check that numeric answer is an
integer, preserve original for errors.
(action_shell): new restart command, error
checking. Document shell to some extent.
git-svn-id: svn://tug.org/texlive/trunk@44189 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/scripts')
-rwxr-xr-x | Master/texmf-dist/scripts/texlive/tlmgr.pl | 128 |
1 files changed, 94 insertions, 34 deletions
diff --git a/Master/texmf-dist/scripts/texlive/tlmgr.pl b/Master/texmf-dist/scripts/texlive/tlmgr.pl index 6ad1ccde64e..f5ce1249910 100755 --- a/Master/texmf-dist/scripts/texlive/tlmgr.pl +++ b/Master/texmf-dist/scripts/texlive/tlmgr.pl @@ -5863,13 +5863,12 @@ sub action_shell { } chomp($ans); if (@options) { - $ans--; - if ($ans >= 0 && $ans <= $#options) { - $ans = $options[$ans]; - return($ans); + if ($ans =~ /^[0-9]+$/ && 0 <= $ans - 1 && $ans - 1 <= $#options) { + $ans = $options[$ans - 1]; } else { - print "ERROR invalid answer\n"; - return; + print "ERROR invalid answer $ans\n"; + # return empty string so caller knows not to continue + $ans = ""; } } if (@guarantee) { @@ -5881,7 +5880,7 @@ sub action_shell { } } if (!$isok) { - print("Please answer one of @guarantee!\n"); + print("Please answer one of: @guarantee\n"); return(do_prompt(@savedargs)); } } @@ -5906,22 +5905,27 @@ sub action_shell { } elsif ($cmd eq "setup-location") { my $dest = shift @args; print "ERROR not implemented: $cmd\n"; + } elsif ($cmd eq "restart") { + exec("tlmgr", @::SAVEDARGV); + } elsif ($cmd =~ m/^(set|get)$/) { - my @valid_bool_keys = qw/debug-translation machine-readable no-execute-actions require-verification verify-downloads/; + my @valid_bool_keys + = qw/debug-translation machine-readable no-execute-actions + require-verification verify-downloads/; my @valid_string_keys = qw/repository/; - my @valid_keys = @valid_bool_keys; - push @valid_keys, @valid_string_keys; + my @valid_keys = (@valid_bool_keys, @valid_string_keys); + # my $key = shift @args; my $val = shift @args; if (!$key) { - $key = do_prompt('Choose...', -menu => \@valid_keys, '>'); + $key = do_prompt('Choose one of...', -menu => \@valid_keys, '>'); } if (!$key) { - print("ERROR missing argument for get\n"); + print("ERROR missing key argument for get/set\n"); next; } if ($cmd eq "get" && defined($val)) { - print("ERROR no argument allowed for get\n"); + print("ERROR argument not allowed for get: $val\n"); next; } if ($cmd eq "set" && !defined($val)) { @@ -5932,7 +5936,7 @@ sub action_shell { } # deal with Ctrl-D if (!defined($val)) { - print("ERROR Missing value for set.\n"); + print("ERROR missing value for set\n"); next; } } @@ -5941,7 +5945,7 @@ sub action_shell { if ($cmd eq "set") { $location = scalar($val); } else { - if (defined($location)) { + if (defined($location) && $location) { print "repository = $location\n"; } else { print "repository = <UNDEFINED>\n"; @@ -5967,7 +5971,7 @@ sub action_shell { } print "OK\n"; } else { - print "ERROR unknown key $key\n"; + print "ERROR unknown get/set key $key\n"; } } elsif ($cmd eq "load") { my $what = shift @args; @@ -5981,7 +5985,7 @@ sub action_shell { init_tlmedia_or_die(); print "OK\n"; } else { - print "ERROR can only load 'local' or 'remote'\n"; + print "ERROR can only load 'local' or 'remote', not $what\n"; } } elsif ($cmd eq "save") { $localtlpdb->save; @@ -5989,7 +5993,7 @@ sub action_shell { } elsif (defined($action_specification{$cmd})) { # an action if (!defined($action_specification{$cmd}{"function"})) { - print "ERROR action function not defined\n"; + print "ERROR undefined action function $cmd\n"; next; } # redo the option parsing @@ -6027,7 +6031,7 @@ sub action_shell { } %opts = %savedopts; } else { - print "ERROR unknown command\n"; + print "ERROR unknown command $cmd\n"; } } } @@ -7152,19 +7156,23 @@ out). If I<value> is given in addition, I<key> is set to I<value> in the respective file. I<No error checking is done!> +The C<PATH> value shown by C<conf> is as used by C<tlmgr>. The +directory in which the C<tlmgr> executable is found is automatically +prepended to the PATH value inherited from the environment. + Here is a practical example of changing configuration values. If the execution of (some or all) system commands via C<\write18> was left enabled during installation, you can disable it afterwards: tlmgr conf texmf shell_escape 0 -The sub-command C<auxtrees> allows adding and -removing arbitrary additional texmf trees, completely under user -control. C<auxtrees show> shows the list of additional trees, -C<auxtrees add> I<tree> adds a tree to the list, and -C<auxtrees remove> I<tree> removes a tree from the list (if present). The -trees should not contain an C<ls-R> file. This works by manipulating the -Kpathsea variable C<TEXMFAUXTREES>, in C<ROOT/texmf.cnf>. Example: +The subcommand C<auxtrees> allows adding and removing arbitrary +additional texmf trees, completely under user control. C<auxtrees show> +shows the list of additional trees, C<auxtrees add> I<tree> adds a tree +to the list, and C<auxtrees remove> I<tree> removes a tree from the list +(if present). The trees should not contain an C<ls-R> file. This works +by manipulating the Kpathsea variable C<TEXMFAUXTREES>, in +C<ROOT/texmf.cnf>. Example: tlmgr conf auxtrees add /quick/test/tree tlmgr conf auxtrees remove /quick/test/tree @@ -7172,13 +7180,10 @@ Kpathsea variable C<TEXMFAUXTREES>, in C<ROOT/texmf.cnf>. Example: In all cases the configuration file can be explicitly specified via the option C<--conffile> I<file>, if desired. -The C<PATH> value shown by C<conf> is as used by C<tlmgr>. The -directory in which the C<tlmgr> executable is found is automatically -prepended to the PATH value inherited from the environment. - -Warning: The general facility is here, but tinkering with settings in -this way is strongly discouraged. Again, no error checking on either -keys or values is done, so any sort of breakage is possible. +Warning: The general facility for changing configuration values is here, +but tinkering with settings in this way is strongly discouraged. Again, +no error checking on either keys or values is done, so any sort of +breakage is possible. =head2 dump-tlpdb [--local|--remote] @@ -7864,8 +7869,63 @@ C<tables> (unless they also contain the word C<table> on its own). =head2 shell -Starts the TeX Live Manager Shell. +Starts an interactive mode, where tlmgr prompts for commands. This can +be used directly, or for scripting. The first line of output is +C<protocol> I<n>, where I<n> is an unsigned number identifying the +protocol version (currently 1). + +In general, tlmgr actions that can be given on the command line +translate to commands in this shell mode. For example, you can say +C<update --list> to see what would be updated. The TLPDB is loaded the +first time it is needed (not at the beginning), and used for the rest of +the session. + +Besides these actions, a few commands are specific to shell mode: + +=over 4 + +=item protocol + +Print C<protocol I<n>>, the current protocol version. +=item help + +Print pointers to this documentation. + +=item version + +Print tlmgr version information. + +=item quit, end, bye, byebye, EOF + +Exit. + +=item restart + +Restart C<tlmgr shell> with the original command line; most useful when +developing C<tlmgr>. + +=item load [local|remote] + +Explicitly load the local or remote, respectively, TLPDB. + +=item save + +Save the local TLPDB, presumably after other operations have changed it. + +=item get [I<var>] +=item set [I<var> [I<val>]] + +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 +like the corresponding command line option. The C<repository> variable +takes a string, and sets the remote repository location. + +If I<var> or then I<val> is not specified, it is prompted for. + +=back =head2 uninstall |