This global variable is provided by tclsh and wish mainline code (and NOT the tcl or tk libraries). 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_FSEvalFile(), 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].
Some code available that helps process the argv arguments include:
What: clig (Kirsch) Where: http://wsd.iitb.fhg.de/%7Ekir/clighome/ Description: Command Line Interpreter Generator creates an interpreter which can recognize flag, float, int or string type options, multi-parameters, rangers, defaults, mandatory arguments, readable usage msgs. Reads a simple description file. Code generates standard C. Currently at v1.9.10 . Contact: mailto:[email protected] (Harald Kirsch) What: CmdLine Where: http://www.enteract.com/%7Ebradapp/ftp/ Description: OODC++ library and driver to parse command line arguments. Written by the author of ParseArgs, but completely redesigned and rewritten - has no dependency on ParseArgs. Updated: 09/1996 Contact: mailto:[email protected] (Brad Appleton) What: evaluate_parameters Where: ftp://ftp.Lehigh.EDU/pub/evap/evap-2.x/evap-2.2.tar.Z ftp://ftp.procplace.com/pub/tcl/sorted/packages-7.6/devel/evap-2.1.tar.gz Description: evaluate_parameters is a Perl program that processes command line arguments in a simple consistent manner performing type-checking, multi-levels of help, etc. generate_tk_program is an auxiliary program which generates a Tcl/Tk GUI wrapper around one's Perl or C program to gather the command line arguments interactively. Updated: 10/1999 Contact: mailto:[email protected] (Stephen O. Lidie) What: ParseArgs Where: From comp.sources.misc archives, volume 29 ftp://wuarchive.wustl.edu/usenet/comp.sources.misc/volume29/parseargs Description: Utility library for parsing command line arguments in various languages (including Tcl) and on various hardware platforms Updated: 09/1996 Contact: mailto:[email protected] (Brad Appleton) What: argp Where: http://www.chevreux.org/projects_tcl.html Description: Simple and flexible argument parsing for Tcl - particularly good for parsing command line arguments or the args proc argument. Supports implicit type and value checking. Currently version 0.2 . Updated: 10/2001 Contact: mailto:[email protected] (Bastien Chevreux) What: argument parsing with defaults (Wagner) Where: From the contact Description: Tcl code to parse arguments and provide default values. See theObjects-2.x for a C version. Updated: Contact: mailto:[email protected] (Juergen Wagner) mailto:[email protected] (Juergen Wagner) What: argument processing for Tcl (Lehenbauer) Where: From the contact Description: Provides Tk-like argument processing to Tcl proc writers. Updated: Contact: [Karl Lehenbauer] What: argument processing (Zimmer) Where: http://www.MapFree.com/sbf/tcl/scripts1.html Description: Tcl based argument processing. Updated: 04/1999 Contact: mailto:[email protected] What: SimpleOpt Where: From the contact Description: Tcl only argument parsing code Updated: 06/1999 Contact: mailto:[email protected] (Juan Carlos Gil Montoro) What: sneaky_eval Where: From the contact Description: Preprocess arguments before calling RecordAndEval or Eval, surrounding the arguments with braces so they won't be sub-evaluated. Updated: Contact: mailto:[email protected] (Matt DiMeo) What: SNTL Where: http://www.csua.berkeley.edu/%7Esls/woa/distrib/ ftp://ftp.procplace.com/pub/tcl/sorted/packages-7.6/devel/sntl-0.4.2.tar.gz ftp://ftp.procplace.com/pub/tcl/sorted/packages-7.6/devel/sntl-0.4.2p1.patch.tar.gz Description: A general Tcl library of procedures. Contains code to produce man pages from Tcl source, conversions from Tcl to C, HTML rendering, generating HTML, handling CGI forms, command line argument processing, a debugging message system, an object system, and various Tk widgets built with the object system. Updated: 10/1998 Contact: mailto:[email protected] (Sam Shen) mailto:[email protected] (Sam Shen) What: variable argument process Where: From the contact Description: Tcl procedure (args) to make handling variable number of procedure arguments and keywords easier to process. Updated: Contact: mailto:[email protected] (Juergen Wagner) What: yaap - Yet Another Argument Parsing utility Where: ftp://ftp.procplace.com/pub/tcl/sorted/packages-7.6/devel/yaap-0.9.shar.gz Description: Template based argument parsing utility, inspired by XtGetApplicationResources() function. Updated: 10/1998 Contact: mailto:[email protected] (Peter Ziobrzynski)