For Programmers: Free Programming Magazines  


Home > Archive > Tcl > June 2006 > Tcl CLI questions









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Tcl CLI questions
Russell Treleaven

2006-06-24, 8:23 am

Hi,

Just for fun I am writing a CLI shell in Tcl.
for now I have decided not to use Tclreadline as I can't find the
documentation to make it work the way I want.(if someone could help me find
decent documentation I might change my mind).

Platform is Linux.
----------------------------------
proc getChar {} {
if { [ eof stdin ] } {
exec /bin/stty -raw echo <@stdin
exit
}
set char [ read stdin ]
if { $char == "\n" } {
set char {}
eval [ list $::data ]
}
puts -nonewline $char
append ::data $char
flush stdout
}
exec /bin/stty raw -echo <@stdin
fconfigure stdin -buffering none -blocking 0 -eofchar "\x04"
fileevent stdin readable getData
puts -nonewline stdout "prompt#"
flush stdout
vwait forever
-----------------------------------
1. I am calling stty so that I can get a character at a time and disable
echo. If the shell crashes it can't clean up after itself so the terminal
is left in a bad state. Is there a better way to do what I wan't to do?

2. I read somewhere a long time ago that programs can check to see if their
standard channels are connected to a terminal. If they are not they use
different buffering. How can I do this in Tcl or by execing something?

Sincerely,

russ@else.net

Russell Treleaven

2006-06-24, 8:23 am

Russell Treleaven wrote:

> Hi,
>
> Just for fun I am writing a CLI shell in Tcl.
> for now I have decided not to use Tclreadline as I can't find the
> documentation to make it work the way I want.(if someone could help me
> find decent documentation I might change my mind).
>


I apologize!
I really didn't mean to cast aspersions on Tclreadline's documentation. I
just have not been able to make it do what I want.

OK we're , right? :)

russ@else.net

Bryan Oakley

2006-06-24, 8:23 am

Russell Treleaven wrote:

> I apologize!
> I really didn't mean to cast aspersions on Tclreadline's documentation. I
> just have not been able to make it do what I want.
>
> OK we're , right? :)
>
> russ@else.net
>


Relax. You're amoung friends here.


--
Bryan Oakley
http://www.tclscripting.com
Gerry Snyder

2006-06-24, 8:23 am

Russell Treleaven wrote:
> Hi,
>
> ....
>
> 2. I read somewhere a long time ago that programs can check to see if their
> standard channels are connected to a terminal. If they are not they use
> different buffering. How can I do this in Tcl or by execing something?


From the tclsh man page:

tcl_interactive
Contains 1 if tclsh is running interactively (no fileName was
specified and standard input is a terminal-like device), 0 otherwise.

HTH,

Gerry
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com