home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / tcl2-73c.zip / tcl7.3 / doc / tclsh.1 < prev    next >
Text File  |  1993-08-26  |  4KB  |  104 lines

  1. '\"
  2. '\" Copyright (c) 1993 The Regents of the University of California.
  3. '\" All rights reserved.
  4. '\"
  5. '\" Permission is hereby granted, without written agreement and without
  6. '\" license or royalty fees, to use, copy, modify, and distribute this
  7. '\" documentation for any purpose, provided that the above copyright
  8. '\" notice and the following two paragraphs appear in all copies.
  9. '\"
  10. '\" IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY
  11. '\" FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
  12. '\" ARISING OUT OF THE USE OF THIS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
  13. '\" CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  14. '\"
  15. '\" THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
  16. '\" INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
  17. '\" AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
  18. '\" ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
  19. '\" PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
  20. '\" 
  21. '\" $Header: /user6/ouster/tcl/man/RCS/tclsh.1,v 1.4 93/08/26 15:06:04 ouster Exp $ SPRITE (Berkeley)
  22. '/" 
  23. .so man.macros
  24. .HS tclsh tclcmds
  25. .BS
  26. '\" Note:  do not modify the .SH NAME line immediately below!
  27. .SH NAME
  28. tclsh \- Simple shell containing Tcl interpreter
  29. .SH SYNOPSIS
  30. \fBtclsh\fR ?\fIfileName arg arg ...\fR?\fR
  31. .BE
  32.  
  33. .SH DESCRIPTION
  34. .PP
  35. \fBTclsh\fR is a shell-like application that reads Tcl commands
  36. from its standard input or from a file and evaluates them.
  37. If invoked with no arguments then it runs interactively, reading
  38. Tcl commands from standard input and printing command results and
  39. error messages to standard output.
  40. It runs until the \fBexit\fR command is invoked or until it
  41. reaches end-of-file on its standard input.
  42. If there exists a file \fB.tclshrc\fR in the home directory of
  43. the user, \fBtclsh\fR evaluates the file as a Tcl script
  44. just before reading the first command from standard input.
  45.  
  46. .SH "SCRIPT FILES"
  47. .PP
  48. If \fBtclsh\fR is invoked with arguments then the first argument
  49. is the name of a script file and any additional arguments
  50. are made available to the script as variables (see below).
  51. Instead of reading commands from standard input \fBtclsh\fR will
  52. read Tcl commands from the named file;  \fBtclsh\fR will exit
  53. when it reaches the end of the file.
  54. There is no automatic evaluation of \fB.tclshrc\fR in this
  55. case, but the script file can always \fBsource\fR it if desired.
  56. .PP
  57. If you create a Tcl script in a file whose first line is
  58. .DS
  59. \fB#!/usr/local/bin/tclsh
  60. .DE
  61. then you can invoke the script file directly from your shell if
  62. you mark the file as executable.
  63. This assumes that \fBtclsh\fR has been installed in the default
  64. location in /usr/local/bin;  if it's installed somewhere else
  65. then you'll have to modify the above line to match.
  66.  
  67. .SH "VARIABLES"
  68. .PP
  69. \fBTclsh\fR sets the following Tcl variables:
  70. .TP 15
  71. \fBargc\fR
  72. Contains a count of the number of \fIarg\fR arguments (0 if none),
  73. not including the name of the script file.
  74. .TP 15
  75. \fBargv\fR
  76. Contains a Tcl list whose elements are the \fIarg\fR arguments,
  77. in order, or an empty string if there are no \fIarg\fR arguments.
  78. .TP 15
  79. \fBargv0\fR
  80. Contains \fIfileName\fR if it was specified.
  81. Otherwise, contains the name by which \fBtclsh\fR was invoked.
  82. .TP 15
  83. \fBtcl_interactive\fR
  84. Contains 1 if \fBtclsh\fR is running interactively (no
  85. \fIfileName\fR was specified and standard input is a terminal-like
  86. device), 0 otherwise.
  87. .LP
  88.  
  89. .SH PROMPTS
  90. .PP
  91. When \fBtclsh\fR is invoked interactively it normally prompts for each
  92. command with ``\fB% \fR''.  You can change the prompt by setting the
  93. variables \fBtcl_prompt1\fR and \fBtcl_prompt2\fR.  If variable
  94. \fBtcl_prompt1\fR exists then it must consist of a Tcl script
  95. to output a prompt;  instead of outputting a prompt \fBtclsh\fR
  96. will evaluate the script in \fBtcl_prompt1\fR.
  97. The variable \fBtcl_prompt2\fR is used in a similar way when
  98. a newline is typed but the current command isn't yet complete;
  99. if \fBtcl_prompt2\fR isn't set then no prompt is output for
  100. incomplete commands.
  101.  
  102. .SH KEYWORDS
  103. argument, interpreter, prompt, script file, shell
  104.