Question

I have a tcl script file called hello.tcl, with the following content:

puts "hello world"

When I run it on bash using the command,

tclsh hello.tcl

I get the hello print.

However, if I use tclsh -f instead of just tclsh above, I don't get any print, only the tcl prompt. Why don't I get any prints in the second case?

Was it helpful?

Solution

tclsh syntax is:

tclsh ?-encoding name? ?fileName arg arg ...?

That means you can call it like this:

tclsh hell.tcl
tclsh -encoding (something) hell.tcl

Anything else is an error. Instead of barking at you, tclsh silently ignores the error and open up the shell.

Tcl Command Notation

I found Tcl command notation a bit strange at first, and could not find any reference any where. However, here are what I understand:

  • The ? ... ? notation means optional
  • Tcl commands use a single dash as opposed to double dash: -encoding instead of '--encoding`

Manual

As for help, I installed ActiveState Tcl 8.5 and it comes with a file called ActiveTclHelp8.5.chm, which is my bible. This file is very detailed, with complete search capability. I cannot give you that file for fear of legal implications, but you can install ActiveState Tcl to get it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top