Home
Main website
Display Sidebar
Hide Ads
Recent Changes
View Source:
tclsh8.3(1)
Edit
PageHistory
Diff
Info
LikePages
tclsh !!!tclsh NAME SYNOPSIS DESCRIPTION SCRIPT FILES VARIABLES PROMPTS KEYWORDS ---- !!NAME tclsh - Simple shell containing Tcl interpreter !!SYNOPSIS __tclsh__ ?''fileName arg arg ...''? ________________________________________________________________________________________________________________________________________ !!DESCRIPTION __Tclsh__ is a shell-like application that reads Tcl commands from its standard input or from a file and evaluates them. If invoked with no arguments then it runs interactively, reading Tcl commands from standard input and printing command results and error messages to standard output. It runs until the __exit__ command is invoked or until it reaches end-of-file on its standard input. If there exists a file __.tclshrc__ (or __tclshrc.tcl__ on the Windows platforms) in the home directory of the user, __tclsh__ evaluates the file as a Tcl script just before reading the first command from standard input. !!SCRIPT FILES If __tclsh__ is invoked with arguments then the first argument is the name of a script file and any additional arguments are made available to the script as variables (see below). Instead of reading commands from standard input __tclsh__ will read Tcl commands from the named file; __tclsh__ will exit when it reaches the end of the file. There is no automatic evaluation of __.tclshrc__ in this case, but the script file can always __source__ it if desired. If you create a Tcl script in a file whose first line is __#!/usr/local/bin/tclsh __ then you can invoke the script file directly from your shell if you mark the file as executable. This assumes that __tclsh__ has been installed in the default location in /usr/local/bin; if it's installed somewhere else then you'll have to modify the above line to match. Many UNIX systems do not allow the __#!__ line to exceed about 30 characters in length, so be sure that the __tclsh__ executable can be accessed with a short file name. An even better approach is to start your script files with the following three lines: __#!/bin/sh # the next line restarts using tclsh \ exec tclsh __ This approach has three advantages over the approach in the previous paragraph. First, the location of the __tclsh__ binary doesn't have to be hard-wired into the script: it can be anywhere in your shell search path. Second, it gets around the 30-character file name limit in the previous approach. Third, this approach will work even if __tclsh__ is itself a shell script (this is done on some systems in order to handle multiple architectures or operating systems: the __tclsh__ script selects one of several binaries to run). The three lines cause both __sh__ and __tclsh__ to process the script, but the __exec__ is only executed by __sh__. __sh__ processes the script first; it treats the second line as a comment and executes the third line. The __exec__ statement cause the shell to stop processing and instead to start up __tclsh__ to reprocess the entire script. When __tclsh__ starts up, it treats all three lines as comments, since the backslash at the end of the second line causes the third line to be treated as part of the comment on the second line. !!VARIABLES __Tclsh__ sets the following Tcl variables: __argc__ Contains a count of the number of ''arg'' arguments (0 if none), not including the name of the script file. __argv__ Contains a Tcl list whose elements are the ''arg'' arguments, in order, or an empty string if there are no ''arg'' arguments. __argv0__ Contains ''fileName'' if it was specified. Otherwise, contains the name by which __tclsh__ was invoked. __tcl_interactive__ Contains 1 if __tclsh__ is running interactively (no ''fileName'' was specified and standard input is a terminal-like device), 0 otherwise. !!PROMPTS When __tclsh__ is invoked interactively it normally prompts for each command with ``__%__ ''. You can change the prompt by setting the variables __tcl_prompt1__ and __tcl_prompt2__. If variable __tcl_prompt1__ exists then it must consist of a Tcl script to output a prompt; instead of outputting a prompt __tclsh__ will evaluate the script in __tcl_prompt1__. The variable __tcl_prompt2__ is used in a similar way when a newline is typed but the current command isn't yet complete; if __tcl_prompt2__ isn't set then no prompt is output for incomplete commands. !!KEYWORDS argument, interpreter, prompt, script file, shell ----
One page links to
tclsh8.3(1)
:
Man1t
This page is a man page (or other imported legacy content). We are unable to automatically determine the license status of this page.