On 04 Nov 2009 16:05:55 -0800, David Larson wrote:
>
> Hi folks,
>
> I decided to try out the pure TCL version today and ran into a
> problem. Perhaps I didn’t set something up right. The problem
> occurred when I sourced the csh file in the init directory. When the
> file was sourced, the process hung. Digging into it, I found that
> $TCLSH was never set in the csh script since my copy of tclsh is in
> a non-standard location. My fix was to change this:
>
<snip>
> Not sure if you think this is a good solution or not, but thought
> I’d offer it just in case.
>
There are two good solutions for this.
One is this kind of bootstrap header on your modulestcl file:
#!/bin/sh
# Bootstrap into tclsh by checking various locations:
# \
[ -x /usr/local/bin/tclsh ] && exec /usr/local/bin/tclsh "$0" "$@"
# \
[ -x /usr/bin/tclsh ] && exec /usr/bin/tclsh "$0" "$@"
# \
[ -x /bin/tclsh ] && exec /bin/tclsh "$0" "$@"
# \
type tclsh 1>/dev/null 2>&1 && exec tclsh "$0" "$@"
# \
echo "FATAL: module: Could not find tclsh in \$PATH or in standard\
directories" >&2; exit 1
Another possibility is to put the bootstrapper into an exec wrapper:
#!/bin/sh
# Shell wrapper to find tclsh in non-standard paths
#
# First, check standard paths:
type tclsh 1>/dev/null 2>&1 && exec tclsh ${1+"$@"}
# Next, search other paths:
export dirlist
dirlist="/usr/local/bin
/usr/bin
/bin"
for dir in $dirlist ; do
if [ -x $dir/tclsh ] ; then
PATH=$PATH:$dir; export PATH
exec tclsh ${1+"$@"}
fi
done
printf "`basename $0`:\nCannot find tclsh in\n\t$dirlist\nor \$PATH\n" >&2
exit 1
And then use
#!/usr/bin/env tcl_wrapper
as the first line of your script.
Of course, you can search more directories if you like. I'm just
giving some examples.
Ted
--
Frango ut patefaciam -- I break so that I may reveal
|