texlive[44189] Master/texmf-dist/scripts/texlive/tlmgr.pl:

commits+karl at tug.org commits+karl at tug.org
Thu May 4 19:31:53 CEST 2017


Revision: 44189
          http://tug.org/svn/texlive?view=revision&revision=44189
Author:   karl
Date:     2017-05-04 19:31:52 +0200 (Thu, 04 May 2017)
Log Message:
-----------
(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.

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-05-04 16:16:54 UTC (rev 44188)
+++ trunk/Master/texmf-dist/scripts/texlive/tlmgr.pl	2017-05-04 17:31:52 UTC (rev 44189)
@@ -5863,13 +5863,12 @@
     }
     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 @@
         }
       }
       if (!$isok) {
-        print("Please answer one of @guarantee!\n");
+        print("Please answer one of: @guarantee\n");
         return(do_prompt(@savedargs));
       }
     }
@@ -5906,22 +5905,27 @@
     } 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 @@
         }
         # 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 @@
         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 @@
         }
         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 @@
         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 @@
     } 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 @@
       }
       %opts = %savedopts;
     } else {
-      print "ERROR unknown command\n";
+      print "ERROR unknown command $cmd\n";
     }
   }
 }
@@ -7152,6 +7156,10 @@
 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:
@@ -7158,13 +7166,13 @@
   
   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,14 +7180,11 @@
 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 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.
 
-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.
-
 =head2 dump-tlpdb [--local|--remote]
 
 Dump complete local or remote TLPDB to standard output, as-is.  The
@@ -7864,9 +7869,64 @@
 
 =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
 
 Uninstalls the entire TeX Live installation.  Options:



More information about the tex-live-commits mailing list