UText Interactive Shell
This page describes the Universaltext Shell as of UText/1.2.
The Perl programm
utshell.pl is a shell for the UText script language both for interactive sessions and batch processing.
The program is located at the
UText directory (see Installation). It is useful to define an alias (in Unix) or a shortcut (in Windows) to the
utshell.pl file, in order to access it easily.
The program uses the Perl module
Term::ReadLine that is part of the core Perl installation. If you want to get command history functionality in the UText Shell, you must have one of the various optional
readline Perl packages installed, for example
perl -MCPAN -e shell install Term::ReadLine::Gnu
See CPAN for more information.
Invoking the program without any arguments starts an interactive shell session.
The examples below show a Unix shell with an alias
ut to the program.
francesc@sil10 ~$ ut Universaltext Interpreter v1.2 beta; +http://u-tx.net (c) 2004-2010 Francesc Hervada-Sala Welcome to the UText Shell. Enter '.' to quit, 'help' for usage. ut>
To get a list of command line arguments invoke the shell with
francesc@sil10 ~$ ut -h Universaltext Interpreter v1.2 beta; +http://u-tx.net (c) 2004-2010 Francesc Hervada-Sala Usage: ut file... [-m module]... [-b] [-r] [-v] [-h] file: one or more utl file to read -m one or more add-in module to load -b batch mode (no interactive session) -r show names of files when reading -v verbose log -h show these usage lines and quit francesc@sil10 ~$
Load Add-In Modules
ut -m types odt
Read UTL Files
One can pass one or more file names as arguments, these files are read by the given order at start up. Separate file names with spaces. If a file name contains a space, the whole name must be quoted. Example:
ut book.utl "my scripts.utl"
After loading the modules and reading the files indicated by the arguments, the lines provided by the standard input stream are executed by the interpreter in batch mode, if the standard input string was redirected. For example:
ut < some-script.scr
This reads and executes the lines of the file
some-script.scr. Note that this input stream is not an UTL file, but an immediate script. To execute an UTL file, pass its name as argument to the shell.
One can also execute here-docs in a Unix shell this way:
francesc@sil10 ~$ ut <<END [.. script instructions here ...] END ut>
Ending Batch Mode
If the standard input stream was not redirected or if its already been completely executed, the batch mode finishes. After the batch mode ends, one enters automatically into the interactive mode. If you do not want the interactive mode to take place, use the command line argument
ut book.utl -b < generate-latex.scr
or include an exit instruction (a single dot) as last instruction in the script.
francesc@sil10 ~$ ut <<END [.. script instructions here ...] . END francesc@sil10 ~$
The only difference between the two options is what happens if an error occurs and execution of the batch script stops. An interactive session starts after the error message only if the program was called without the
-b argument (because the dot does not get executed).
With the command line option
-r the names of the files are printed out at the console as the files are being read. The option
-v activates the verbose debug mode. These are the same as the script instruction
set debug to file and
set debug to say respectively (see Setting
In interactive mode the shell waits for user input and interprets each single line as it is fed. The shell prompt ”ut>“ indicates that the interpreter is ready for accepting new input.
An overwiew over the script usage is shown with the instruction
Any script instruction can be executed. For a description of the script language see Universaltext Script.
In an interactive session, with the arrow up and down keys one can navigate through previous script commands, the tab key has completion for file names.
After leaving the shell, the command history is saved at a file named
.utshell.history at the current directory. When running the shell the next time, this file is read and the command history persists.
When starting an interactive session, the command history is read from current working directory, and when leaving it the new history is saved at the same file, so that starting the shell from different directories results in different command histories.
History and completion functionality pressuposes that a Perl
readline library has been installed (see above installation).
To quit the interactive session, enter a single dot:
francesc@sil10 ~$ ut Universaltext Interpreter v1.2 beta; +http://u-tx.net (c) 2004-2010 Francesc Hervada-Sala Welcome to the UText Shell. Enter '.' to quit, 'help' for usage. ut> . francesc@sil10 ~$
If a line is fed but the script instruction is not complete, the interpreter shows the prompt ”ut...>“ and waits for more lines until the whole instruction is complete before executing them. A multiple line instruction can be aborted entering a single dot:
ut...> . ut>
The following tag is defined by this program in interactive mode (s. Tags for details):
- help: shell usage