1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
|
#
# costinit.tcl
# Initialization file for Cost 2
# 1.15
#
global COST COSTLIB env
if {![info exists COST] || $COST(MAJOR) != 2 || $COST(MINOR) != 2} {
set errmsg "Warning: Cost version mismatch: expected Cost 2.2"
if {[info exists COST]} { append errmsg ", got $COST(VERSION)" }
puts stderr $errmsg
}
#
# Try to figure out library path:
#
if {[info exists env(COSTLIB)]} {
set COSTLIB $env(COSTLIB)
} elseif {![info exists COSTLIB]} {
if {[catch {
set COSTLIB [file join [file dirname [info library]] cost2.2]
}]} {
set COSTLIB /usr/local/lib/cost2.2
}
}
global COST(searchPath); # Search path for 'require' command
if {[info exists env(COSTPATH)]} {
set COST(searchPath) [split $env(COSTPATH) ":"]
}
lappend COST(searchPath) $COSTLIB
#
# Load core utilities:
#
source $COSTLIB/Core.tcl
### costsh-specific commandline processing:
#
# costsh [-S specfile]
#
proc cost_commandline {} {
global argv
set filter 0
while {[string match "-*" $argv]} {
switch -glob -- [set option [lindex $argv 0]] {
-S {
shift argv
set specfile [shift argv]
set filter 1
break;
}
-f {
shift argv
set filter 1
}
-- { shift argv; break }
--* {
break
}
default {
return -code error "unrecognized option $option"
}
}
}
if {$filter} {loadsgmls stdin}
if {[info exists specfile]} {
require $specfile
if { [lsearch [info procs] main] != -1 } { main }
}
}
#*EOF*
|