Updated 2011-12-17 23:56:42 by RLE

Many folks work in a mixed shell environment. To assist the un-enlightened, often a tcl or tk script is called from another shell.

For example:
 #!/bin/sh
 #\
 exec tclsh "$0" ${1+"$@"}

The "#\" gets skipped because /bin/sh thinks it is a comment. When the script calls itself with the "exec $0", Tcl reads the "#\" line as a continuation of a comment, and skips over it to the next line.

The problem with this is that sometimes we get used to our personal environments, and our scripts break when someone else runs them.

The good news is that the same idea works for other environmental variables.
 #!/bin/sh
 #\
 PATH=${PATH}:/path/to/tclsh/and/wish
 #\
 LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/lib
 #\
 export PATH LD_LIBRARY_PATH
 #\
 exec tclsh "$0" ${1+"$@"}

LH