0

When you build Tcl/Tk by default it creates the files

tclsh85
wish85

However many programs call tclsh and wish. This is one fix for that

cp tclsh85 tclsh
cp wish85 wish

However, can you simply build tclsh and wish directly, perhaps using a configure argument?

Zombo
  • 1
  • 62
  • 391
  • 407

2 Answers2

3

This behavior is The Right Thing as it allows several versions of the interpreter and its libraries to coexist in the system. The system, in turn, does provide a way to "bless" one of the version as "default" — for instance, Debian provides "alternatives". In essence, usually a symlink with the "canonical" name is created pointing to the real executable, like /usr/bin/tclsh/usr/bin/tclsh85. And with the "blessed" version available via such a symlink for the applications that do not care about the precise version of the runtime, certain other applications still can pick some specific runtime version by referring to the interpreter's real executable name.

This also provides an easy way to test an existing program against an experimental runtime version: you just run /usr/bin/tclsh86 /path/to/the/script.tcl instead of just running /path/to/the/script.tcl as usually which relies on the shebang to pick the interpreter.

kostix
  • 51,517
  • 14
  • 93
  • 176
0

A long time ago, the builds of Tcl and Tk used to work in the way you describe. It was changed to the current system (putting the version number in the name) to allow multiple versions to coexist more smoothly; this was a very strong demand from the user community at the time.

Symlink the version-less filenames to the real ones (or use the mechanism of your distribution) if you want to give up control over which version to use. Alternatively, use this (fairly horrible) piece of mixed shell/Tcl code at the top of your files:

#!/bin/sh
# Try with a versionless name \
exec tclsh "$0" ${1+"$@"}
# Otherwise, try with tclsh8.6 \
exec tclsh8.6 "$0" ${1+"$@"}
# Otherwise, try with tclsh8.5 \
exec tclsh8.5 "$0" ${1+"$@"}
# Otherwise, try with tclsh8.4 \
exec tclsh8.4 "$0" ${1+"$@"}
# Otherwise... well... give up! \
echo "no suitable Tcl interpreter" >&1; exit 1

This relies on the fact that Tcl, unlike the Unix shell, treats a \ at the end of a comment line as meaning that the comment extends onto the next line.

(Myself? I don't usually put in #! lines these days; I don't consider it an imposition to write tclsh8.5 myscript.tcl.)

Donal Fellows
  • 133,037
  • 18
  • 149
  • 215