@@ -1,6 +1,5 @@ -#!/usr/locanl/bin/tclsh # FILE: "/home/joze/src/tclreadline/tclreadlineSetup.tcl.in" # LAST MODIFICATION: "Mit, 10 Jan 2001 06:29:34 +0100 (joze)" # (C) 1998 - 2001 by Johannes Zellner, # $Id$ # --- @@ -134,11 +133,11 @@ if {"" == [info commands ::tclreadline::readline]} { ::tclreadline::Init } - if {[catch {set a [::tclreadline::prompt1]}] && [info nameofexecutable] != ""} { + if {"" == [info procs ::tclreadline::prompt1] && [info nameofexecutable] != ""} { namespace eval ::tclreadline { variable prompt_string set base [file tail [info nameofexecutable]] @@ -168,10 +167,20 @@ return "$prompt_string \[$pwd\]" } } # puts body=[info body ::tclreadline::prompt1] } + + if {"" == [info procs ::tclreadline::prompt2] && [info nameofexecutable] != ""} { + + if {"" == [info procs ::tclreadline::prompt2]} { + proc ::tclreadline::prompt2 {} { + return ">" + } + } + # puts body=[info body ::tclreadline::prompt2] + } if {"" == [info procs exit]} { catch {rename ::tclreadline::Exit ""} rename exit ::tclreadline::Exit @@ -261,26 +270,25 @@ uplevel #0 { while {1} { - if [info exists tcl_prompt2] { - set prompt2 $tcl_prompt2 - } else { - set prompt2 ">" - } - if {[catch { if {"" != [namespace eval ::tclreadline {info procs prompt1}]} { - set LINE [::tclreadline::readline read \ + set ::tclreadline::LINE [::tclreadline::readline read \ [::tclreadline::prompt1]] } else { - set LINE [::tclreadline::readline read %] + set ::tclreadline::LINE [::tclreadline::readline read %] } - while {![::tclreadline::readline complete $LINE]} { - append LINE "\n" - append LINE [tclreadline::readline read ${prompt2}] + while {![::tclreadline::readline complete $::tclreadline::LINE]} { + append ::tclreadline::LINE "\n" + if {"" != [namespace eval ::tclreadline {info procs prompt2}]} { + append ::tclreadline::LINE \ + [tclreadline::readline read [::tclreadline::prompt2]] + } else { + append ::tclreadline::LINE [tclreadline::readline read >] + } } } ::tclreadline::errorMsg]} { puts stderr [list tclreadline::Loop: error. \ $::tclreadline::errorMsg] continue @@ -292,23 +300,24 @@ # I decided to add only lines which are different from # the previous one to the history. This is different # from tcsh's behaviour, but I found it quite convenient # while using mshell on os9. # - if {[string length $LINE] && [history event 0] != $LINE} { - history add $LINE + if {[string length $::tclreadline::LINE] && \ + [history event 0] != $::tclreadline::LINE} { + history add $::tclreadline::LINE } if [catch { - set result [eval $LINE] - if {$result != "" && [tclreadline::Print]} { - puts $result + set ::tclreadline::result [eval $::tclreadline::LINE] + if {$::tclreadline::result != "" && [tclreadline::Print]} { + puts $::tclreadline::result } - set result "" + set ::tclreadline::result "" } ::tclreadline::errorMsg] { puts stderr $::tclreadline::errorMsg - puts stderr [list while evaluating $LINE] + puts stderr [list while evaluating $::tclreadline::LINE] } } } }