1 # Try to open the executable as a database and read the "scripts.data"
2 # field where "scripts.name" is 'main.tcl'
5 if {![file exists
$argv0] && [file exists
$argv0.exe
]} {
8 sqlite3 db
$argv0 -vfs apndvfs
-create 0
9 set mainscript
[db one
{
10 SELECT sqlar_uncompress
(data
,sz
) FROM sqlar WHERE name
='main.tcl'
13 if {[info exists mainscript
]} {
20 # Try to open file named in the first argument as a database and
21 # read the "scripts.data" field where "scripts.name" is 'main.tcl'
23 if {[llength $argv]>0 && [file readable
[lindex $argv 0]]} {
25 sqlite3 db
[lindex $argv 0] -vfs apndvfs
-create 0
26 set mainscript
[db one
{SELECT data FROM scripts WHERE name
='main.tcl'
}]
27 set argv0
[lindex $argv 0]
28 set argv
[lrange $argv 1 end
]
30 if {[info exists mainscript
]} {
36 if {[string match
*.tcl
[lindex $argv 0]]} {
37 set fd
[open [lindex $argv 0] rb
]
38 set mainscript
[read $fd]
41 set argv0
[lindex $argv 0]
42 set argv
[lrange $argv 1 end
]
44 if {[info exists mainscript
]} {
50 # If all else fails, do an interactive loop
53 while {![eof stdin
]} {
60 append line
[gets stdin
]
61 if {[info complete
$line]} {
62 if {[catch {uplevel #0 $line} result]} {
63 puts stderr
"Error: $result"
64 } elseif
{$result!=""} {