tcltest: do a better job of cleanup up after tests
[jimtcl.git] / rlprompt.tcl
blobcdd78d4cfedc01b669017cbdb232dbfea7331ea0
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 # }
12 package require readline
14 proc rlprompt.shell {} {
15 puts "Readline shell loaded"
16 puts "Welcome to Jim [info version]!"
17 set prompt ". "
18 set buf ""
19 while 1 {
20 set line [readline.readline $prompt]
22 if {[string length $line] == 0} {
23 continue
25 if {$buf eq ""} {
26 set buf $line
27 } else {
28 append buf \n $line
30 if {![info complete $buf]} {
31 set prompt "> "
32 continue
34 readline.addhistory $buf
36 catch {
37 uplevel #0 $buf
38 } error
39 if {$error ne ""} {
40 puts $error
42 set buf ""
43 set prompt ". "