1 |
#! /bin/sh |
#! /bin/sh |
2 |
# The next line restarts using tclsh \ |
# The next line restarts using tclsh \ |
3 |
exec tclsh8.4 "$0" ${1+"$@"} |
exec tclsh8.3 "$0" ${1+"$@"} |
4 |
|
|
5 |
# $Id$ |
# $Id$ |
6 |
# |
# |
7 |
# Copyright (C) 2003 FireEgl (Philip Moore) <FireEgl@Tcldrop.Tk> |
# Copyright (C) 2003 FireEgl (Philip Moore) <FireEgl@Tcldrop.Tk> |
8 |
# |
# |
9 |
# This program is free software; you can redistribute it and/or |
# This program is free software; you can redistribute it and/or |
10 |
# modify it under the terms of the GNU General Public License |
# modify it under the terms of the GNU General Public License |
11 |
# as published by the Free Software Foundation; either version 2 |
# as published by the Free Software Foundation; either version 2 |
12 |
# of the License, or (at your option) any later version. |
# of the License, or (at your option) any later version. |
13 |
# |
# |
14 |
# This program is distributed in the hope that it will be useful, |
# This program is distributed in the hope that it will be useful, |
15 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
16 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17 |
# GNU General Public License for more details. |
# GNU General Public License for more details. |
18 |
# |
# |
19 |
# You should have received a copy of the GNU General Public License |
# You should have received a copy of the GNU General Public License |
20 |
# along with this program (see gpl.txt); if not, write to the |
# along with this program (see gpl.txt); if not, write to the |
21 |
# Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
# Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
22 |
# Or visit http://www.GNU.Org/licenses/gpl.html |
# Or visit http://www.GNU.Org/licenses/gpl.html |
23 |
# |
# |
24 |
# The author of this project can be reached at FireEgl@Tcldrop.Tk |
# The author of this project can be reached at FireEgl@Tcldrop.Tk |
25 |
# Or can be found on IRC (EFNet or FreeNode) as FireEgl. |
# Or can be found on IRC (EFNet or FreeNode) as FireEgl. |
26 |
|
|
77 |
} |
} |
78 |
} |
} |
79 |
if {${background}} { |
if {${background}} { |
80 |
#puts "Launched into the background (pid: ?)" |
if {![catch { package require Tclx }]} { |
81 |
# FixMe: Expect's [fork] command should do what I want here right? |
if {[set pid [fork]] != 0} { |
82 |
# Well, I tried it, and it does..sorta.. |
puts "Launched into the background (using TclX) (pid: $pid)" |
83 |
# but fileevent's are never triggered when it's running in the background, |
exit |
84 |
# other than that everything works. |
} else { |
85 |
# It was probably a bug in the Expect version I tried (5.38). |
vwait forever |
86 |
puts "Sorry, background mode doesn't work yet. =(" |
} |
87 |
puts "Please re-run with the -n option." |
} elseif {![catch { package require Expect }]} { |
88 |
|
if {[set pid [fork]] != 0} { |
89 |
|
puts "Launched into the background (using Expect) (pid: $pid)" |
90 |
|
exit |
91 |
|
} else { |
92 |
|
disconnect |
93 |
|
vwait forever |
94 |
|
} |
95 |
|
} else { |
96 |
|
puts {NOTICE: Running in foreground mode.} |
97 |
|
puts {You need either Expect or TclX for background mode to work.} |
98 |
|
puts {main: entering loop} |
99 |
|
vwait forever |
100 |
|
} |
101 |
} else { |
} else { |
102 |
puts {main: entering loop} |
puts {main: entering loop} |
103 |
vwait forever |
vwait forever |