summaryrefslogtreecommitdiffstats
path: root/doc/tclsh.1
diff options
context:
space:
mode:
Diffstat (limited to 'doc/tclsh.1')
-rw-r--r--doc/tclsh.122
1 files changed, 10 insertions, 12 deletions
diff --git a/doc/tclsh.1 b/doc/tclsh.1
index d9fe95e..2819408 100644
--- a/doc/tclsh.1
+++ b/doc/tclsh.1
@@ -14,7 +14,6 @@ tclsh \- Simple shell containing Tcl interpreter
.SH SYNOPSIS
\fBtclsh\fR ?-encoding \fIname\fR? ?\fIfileName arg arg ...\fR?
.BE
-
.SH DESCRIPTION
.PP
\fBTclsh\fR is a shell-like application that reads Tcl commands
@@ -28,15 +27,11 @@ 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.
-.VE 8.5
-Any additional arguments
+the text data stored in that script file. 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
@@ -58,9 +53,11 @@ 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
@@ -72,11 +69,13 @@ 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
@@ -101,28 +100,30 @@ 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 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
@@ -137,13 +138,10 @@ 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"
encoding(n), fconfigure(n), tclvars(n)
-
.SH KEYWORDS
-argument, interpreter, prompt, script file, shell
+application, argument, interpreter, prompt, script file, shell