Version 19 of argv

Updated 2001-10-30 19:53:53

This global variable is provided by tclsh and wish. It gives you the arguments the app was called with as a list, similar to C's argv, but without the app name itself (you get that in ::argv0). We don't need argc as we can always determine [llength $argv].

DGP -- It is true that we do not need ::argc, but tclsh and wish and any application embedding Tcl that calls Tcl_Main() provide it anyway.

argv0 describes the name of the top-level script that was invoked via tclsh or wish.

http://purl.org/tcl/home/man/tcl8.3.2/UserCmd/tclsh.htm

http://purl.org/tcl/home/man/tcl8.3.2/UserCmd/wish.htm

See command options for a discussion of various options one has in parsing the argv (and argv-like) information.

Also, note that [info script] describes the name of the currently executing script and this name even gets set by source. Technically, it is set by Tcl_EvalFile(), for those using Tcl's C API.

The command [info nameofexecutable] describes the name of the executing binary, and might be thought more like the C level argv[0].


Tcl syntax help - Arts and crafts of Tcl-Tk programming