table of contents
other languages
tclsh(1) | Tcl Applications | tclsh(1) |
NAME¶
tclsh - 包含 Tcl 解釋器的簡單的 shell總覽 SYNOPSIS¶
tclsh ?fileName arg arg ...?描述¶
Tclsh 是一個 shell 類應用程序,從它的標準輸入或一個文件讀 Tcl 命令並對其求值(evaluate)。 如果你不加參數的調用,則它交互式的執行,從標準輸入讀 Tcl 命令並向標準輸出打印命令結果和出錯信息。它一直運行直到調用 exit 命令或在它的標準輸入上讀到文件結束。如果在用戶的主(home)目錄裏存在一個文件 .tclshrc (或在 Windows 平臺上的 tclshrc.tcl),在從標準輸入讀第一條命令之前,tclsh 把這個文件作爲一個 Tcl 腳本來求值。腳本文件 SCRIPT FILES¶
如果加參數調用 tclsh 則第一個參數是腳本文件的名字而任何額外的參數作爲給腳本使用的變量(見後)。 tclsh 將從指名的文件中讀 Tcl 命令而不是從標準輸入讀取;當到達文件結束時 tclsh 將退出。在這種情況下不自動的對 .tclshrc 求值,如果需要的話,腳本文件總是可以 source(包含)它。如果你建立的 Tcl 腳本文件的第一行是
#!/usr/local/bin/tclsh
一個更好的途徑是用下面三行來開始你的腳本文件:
#!/bin/sh # the next line restarts using tclsh \ exec tclsh "$0" "$@"
You should note that it is also common practise to install tclsh with 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.
變量 VARIABLES¶
Tclsh 設置了下列 Tcl 變量:- argc
- 包含 arg 參數的個數(沒有則爲 0),不包括腳本文件的名字。
- argv
- 包含一個 Tcl 列表,其元素依次是 arg 參數,如果沒有 arg 參數則是一個空串。
- argv0
- 如果指定了 fileName 則在此包含。否則。包含調用 tclsh 使用的名字。
- tcl_interactive
- 如果交互式運行 tclsh 則包含 1(不指定fileName 並且標準輸入是一個終端類設備),否則是 0。
提示符 PROMPTS¶
當交互式的調用 tclsh 時,它通常爲每條命令提示“%”。你可以通過設置變量 tcl_prompt1 和 tcl_prompt2 來改變提示符。如果存在變量 tcl_prompt1 則它必須由一個輸出一個提示符的 Tcl 腳本組成;tclsh 對 tcl_prompt1 中的腳本求值而不是輸出一個提示符。變量 tcl_prompt2 以類似的方式用在鍵入了換行而當前命令卻不完整的時候;如果沒設置 tcl_prompt2 則對不完整的命令不給以提示符。關鍵字 KEYWORDS¶
argument, interpreter, prompt, script file, shell[中文版維護人]¶
寒蟬退士[中文版最新更新]¶
2001/06/20《中國linux論壇man手冊頁翻譯計劃》:¶
跋¶
本頁面中文版由中文 man 手冊頁計劃提供。中文 man 手冊頁計劃:../../man-pages-zh/manpages-zh
Tcl |