aio recvfrom was not null terminating the result
[jimtcl.git] / rlprompt.tcl
blob1d8860eabf288b6fe86f41c7bb23d905e6911b7b
1 # Readline-based interactive shell for Jim
2 # Copyright(C) 2005 Salvatore Sanfilippo <antirez@invece.org>
4 # In order to automatically have readline-editing features
5 # put this in your $HOME/.jimrc
7 # if {$jim_interactive} {
8 # if {[catch {package require rlprompt}] == 0} {
9 # rlprompt.shell
10 # }
11 # }
13 proc rlprompt.shell {} {
14 puts "Readline shell loaded"
15 puts "Welcome to Jim [info version]!"
16 set prompt ". "
17 set buf ""
18 while 1 {
19 try -exit {
20 set line [readline.readline $prompt]
21 } on exit dummy {
22 break
25 if {[string length $line] == 0} {
26 continue
28 if {$buf eq ""} {
29 set buf $line
30 } else {
31 append buf \n $line
33 if {![info complete $buf]} {
34 set prompt "> "
35 continue
37 readline.addhistory $buf
39 catch {
40 uplevel #0 $buf
41 } error
42 if {$error ne ""} {
43 puts $error
45 set buf ""
46 set prompt ". "