Re: detect batch mode in Tcl shell
- From: "Gerald W. Lester" <Gerald.Lester@xxxxxxx>
- Date: Fri, 07 Jul 2006 18:36:21 -0500
Donal K. Fellows wrote:
Donald Arseneau wrote:"Gerald W. Lester" <Gerald.Lester@xxxxxxx> writes:What tcl_interactive tells you is are you running wish/tclsh if you invokedA modern standard test for "batch" mode is isatty(stdin), which
it with a startup script or not.
seems to correspond ro what tcl_interactive reports.
Not really. If tclsh is running a script, it isn't interactive even if
stdin is a TTY. :-) Instead, the real equivalent to that check (in 8.4)
is to examine the list of options returned by [fconfigure stdin], which
will look different (on unix at least) if the terminal is a TTY.
However, since the original questioner was really asking about loading
Tk, the best check is probably whether a DISPLAY environment variable
has been set. If not, you're definitely not interactive, and a [package
require Tk] will fail. No idea how to port this conceptual check to
systems not using X11 for display.
Unless he is on MS Windows.
--
+--------------------------------+---------------------------------------+
| Gerald W. Lester |
|"The man who fights for his ideals is the man who is alive." - Cervantes|
+------------------------------------------------------------------------+
.
- Follow-Ups:
- Re: detect batch mode in Tcl shell
- From: Donal K. Fellows
- Re: detect batch mode in Tcl shell
- References:
- detect batch mode in Tcl shell
- From: S-Y. Chen
- Re: detect batch mode in Tcl shell
- From: Gerald W. Lester
- Re: detect batch mode in Tcl shell
- From: Donald Arseneau
- Re: detect batch mode in Tcl shell
- From: Donal K. Fellows
- detect batch mode in Tcl shell
- Prev by Date: Re: detect batch mode in Tcl shell
- Next by Date: Re: Translucent filling of polygons?
- Previous by thread: Re: detect batch mode in Tcl shell
- Next by thread: Re: detect batch mode in Tcl shell
- Index(es):
Relevant Pages
|