Tycho includes a few different ways of running subprocesses.
::tycho::invoke args
exec command.
::tycho::Exec
Consult the tcl man pages for open and exec
for descriptions of platform dependencies.
exec on the MacintoshNeither ::tycho::invoke or the Exec class
will work on the Macintosh, so all methods that call these two methods
should check the $tcl_platform variable at the top of the
method and call error with an informative error message.
body ::tycho::MyClass::myMethod {} {
global tcl_platform
if {$tcl_platform(platform) == "macintosh"} {
error "Sorry, the myMethod method in MyClass is not\
supported on the Macintosh as it\ncalls the\
tcl \"exec\" command which is not available."
}
# The rest of the method . . .
}
In addition, any menu choice that calls a method that eventually
calls exec should be disabled on the Macintosh. In the
example below, from $TYCHO/kernel/Edit.itcl, we
check the tcl_platform variable and disable the menu item
if we are on the mac
body ::tycho::Edit::constructor {args} {
global tcl_platform
# . . .
$myMenubar add "Spelling..." Edit -underline 2 \
-accelerator "M-$" -command "$this spellCheck"
if {$tcl_platform(platform) != unix} {
$myMenubar disable "Spelling..."
}
exec under Windowsexec commmand works under Windows, but there are
various limitations, see the Tcl exec man page.
Some of the classes in Tycho include execs of external commands
that are not shipped with Tycho. The Tycho policy is to allow these
commands to be exec'd under Windows, as the user may have
installed third-party commands.
exec date.
Instead, call clock format [clock seconds].
file
command has been extended with subcommands that copy,
delete, and rename files. In addition,
there is a file subcommand that will make a directory.
The tycho procs ::tycho::rm and ::tycho::mkdir
can be uses with Itcl2.1 and Itcl2.2. These procs check the itcl
version number and then act accordingly.
exec chmod ... calls with
catch so that the command does not fail on non-unix
platforms. The details of file permissions on non-Unix are a little
murky, but wrapping catch around the chmod
call will probably make your code more robust.
::tycho::invoke rather than just calling
exec. If there is a problem,
::tycho::invoke will bring up an error window that includes
the command that failed to exec.