For one reason, on some systems, you can rigidly lock down what executables can be run in a shebang line. In other words, it may refuse to run anything not in /bin
. Or maybe, if your administrators are particularly sadistic, they may try to force everyone to use zsh
:-)
Secondly, this will run tclsh
based on your current path settings. That's invaluable if you want different users to run it with different versions of TCL. Otherwise, you have to give an absolute path on the shebang line and this may be different on different systems (although /usr/bin/env
can also take care of that).
It's also handy to test the scripts with more recent versions of tclsh
before committing to them. For example, you can have tclsh 8.5 under the current latest Debian (7.1) while testing TCL 8.6 by building it in $HOME/staging/tcl86
and changing your path so that directory appears before usr/bin
.
On my system (which is locked down to my specs but no further), the script:
#!/usr/bin/env tclsh
puts $tcl_version
works just fine, outputting:
8.5
So does the script:
#!/usr/bin/tclsh
puts $tcl_version
although, as mentioned, it's tied to the system version of tclsh
rather than the first one on my path.
And, yes, you can get at the arguments just fine, as per the following transcript:
pax> cat qq.tcsh
#!/usr/bin/tclsh
puts $argc
puts $argv
pax> qq.tcsh my name is pax
4
my name is pax