summaryrefslogtreecommitdiffstats
path: root/doc/tclsh.1
diff options
context:
space:
mode:
Diffstat (limited to 'doc/tclsh.1')
-rw-r--r--doc/tclsh.132
1 files changed, 16 insertions, 16 deletions
diff --git a/doc/tclsh.1 b/doc/tclsh.1
index 6ed5eb6..d40ac55 100644
--- a/doc/tclsh.1
+++ b/doc/tclsh.1
@@ -12,8 +12,9 @@
.SH NAME
tclsh \- Simple shell containing Tcl interpreter
.SH SYNOPSIS
-\fBtclsh\fR ?\fB\-encoding \fIname\fR? ?\fIfileName arg arg ...\fR?
+\fBtclsh\fR ?-encoding \fIname\fR? ?\fIfileName arg arg ...\fR?
.BE
+
.SH DESCRIPTION
.PP
\fBTclsh\fR is a shell-like application that reads Tcl commands
@@ -27,11 +28,15 @@ If there exists a file \fB.tclshrc\fR (or \fBtclshrc.tcl\fR on
the Windows platforms) in the home directory of
the user, interactive \fBtclsh\fR evaluates the file as a Tcl script
just before reading the first command from standard input.
+
.SH "SCRIPT FILES"
.PP
+.VS 8.5
If \fBtclsh\fR is invoked with arguments then the first few arguments
specify the name of a script file, and, optionally, the encoding of
-the text data stored in that script file. Any additional arguments
+the text data stored in that script file.
+.VE 8.5
+Any additional arguments
are made available to the script as variables (see below).
Instead of reading commands from standard input \fBtclsh\fR will
read Tcl commands from the named file; \fBtclsh\fR will exit
@@ -53,11 +58,9 @@ of a script file is presented on the \fBtclsh\fR command
line, but the script file can always \fBsource\fR it if desired.
.PP
If you create a Tcl script in a file whose first line is
-.PP
.CS
\fB#!/usr/local/bin/tclsh\fR
.CE
-.PP
then you can invoke the script file directly from your shell if
you mark the file as executable.
This assumes that \fBtclsh\fR has been installed in the default
@@ -69,13 +72,11 @@ executable can be accessed with a short file name.
.PP
An even better approach is to start your script files with the
following three lines:
-.PP
.CS
\fB#!/bin/sh
# the next line restarts using tclsh \e
exec tclsh "$0" ${1+"$@"}\fR
.CE
-.PP
This approach has three advantages over the approach in the previous
paragraph. First, the location of the \fBtclsh\fR binary does not have
to be hard-wired into the script: it can be anywhere in your shell
@@ -100,38 +101,34 @@ its version number as part of the name. This has the advantage of
allowing multiple versions of Tcl to exist on the same system at once,
but also the disadvantage of making it harder to write scripts that
start up uniformly across different versions of Tcl.
+
.SH "VARIABLES"
.PP
-\fBTclsh\fR sets the following global Tcl variables in addition to those
-created by the Tcl library itself (such as \fBenv\fR, which maps
-environment variables such as \fBPATH\fR into Tcl):
+\fBTclsh\fR sets the following Tcl variables:
.TP 15
\fBargc\fR
-.
Contains a count of the number of \fIarg\fR arguments (0 if none),
not including the name of the script file.
.TP 15
\fBargv\fR
-.
Contains a Tcl list whose elements are the \fIarg\fR arguments,
in order, or an empty string if there are no \fIarg\fR arguments.
.TP 15
\fBargv0\fR
-.
Contains \fIfileName\fR if it was specified.
Otherwise, contains the name by which \fBtclsh\fR was invoked.
.TP 15
\fBtcl_interactive\fR
-.
Contains 1 if \fBtclsh\fR is running interactively (no
\fIfileName\fR was specified and standard input is a terminal-like
device), 0 otherwise.
+
.SH PROMPTS
.PP
When \fBtclsh\fR is invoked interactively it normally prompts for each
command with
.QW "\fB% \fR" .
-You can change the prompt by setting the global
+You can change the prompt by setting the
variables \fBtcl_prompt1\fR and \fBtcl_prompt2\fR. If variable
\fBtcl_prompt1\fR exists then it must consist of a Tcl script
to output a prompt; instead of outputting a prompt \fBtclsh\fR
@@ -140,10 +137,13 @@ The variable \fBtcl_prompt2\fR is used in a similar way when
a newline is typed but the current command is not yet complete;
if \fBtcl_prompt2\fR is not set then no prompt is output for
incomplete commands.
+
.SH "STANDARD CHANNELS"
.PP
See \fBTcl_StandardChannels\fR for more explanations.
+
.SH "SEE ALSO"
-auto_path(n), encoding(n), env(n), fconfigure(n)
+encoding(n), fconfigure(n), tclvars(n)
+
.SH KEYWORDS
-application, argument, interpreter, prompt, script file, shell
+argument, interpreter, prompt, script file, shell