Hi!
Looks like wish has an undocumented option -help (or -h) which prints usage info. Usually, after printing usage info an application exits with non-zero status, but wish tries to continue and exits with "Application initialization failed" error or even further with some other error indicating the Tk isn't loaded.
For example, starting Tk 8.6 widgets demo by
wish8.6 /usr/share/doc/tk8.6/examples/widget -h
gives the following:
Application initialization failed: Command-specific options:
-colormap: Colormap for main window
-display: Display to use
-geometry: Initial geometry for window
-name: Name to use for application
-sync: Use synchronous mode for display server
-visual: Visual for main window
-use: Id of window in which to embed application
--: Pass all remaining arguments through to script
Error in startup script: Command-specific options:
-colormap: Colormap for main window
-display: Display to use
-geometry: Initial geometry for window
-name: Name to use for application
-sync: Use synchronous mode for display server
-visual: Visual for main window
-use: Id of window in which to embed application
--: Pass all remaining arguments through to script
(processing arguments in argv variable)
invoked from within
"load /usr/lib/libtk8.6.so.0 Tk"
("package ifneeded Tk 8.6b1" script)
invoked from within
"package require Tk 8.5"
(file "/usr/share/doc/tk8.6/examples/widget" line 16)
wish8.6 -h /usr/share/doc/tk8.6/examples/widget
gives the following:
Application initialization failed: Command-specific options:
-colormap: Colormap for main window
-display: Display to use
-geometry: Initial geometry for window
-name: Name to use for application
-sync: Use synchronous mode for display server
-visual: Visual for main window
-use: Id of window in which to embed application
--: Pass all remaining arguments through to script
I think that there could be two ways to fix this bug:
1) Make wish exit right after printing command line options and document -help option.
2) Remove -help option completely.
According to the doc:
TK_ARGV_NO_DEFAULTS. Normally, Tk_ParseArgv searches an internal table of standard argument specifiers in addition to argTable. If this bit is set in flags, then Tk_ParseArgv will use only argTable and not its default table.
This means that Tk_ParseArgv doesn't work as documented: Tk uses this flag to disable the -help option, but it isn't really disabled. So, I would go for option 2) as suggested.
Here is the patch (just inline, because it is so small).
*** tkArgv.c.orig Sun Nov 9 21:12:49 2008
--- tkArgv.c Mon Aug 31 09:53:15 2009
***************
*** 116,121 ****
--- 116,124 ----
if (i == 0) {
infoPtr = argTable;
} else {
+ if (flags & TK_ARGV_NO_DEFAULTS) {
+ continue;
+ }
infoPtr = defaultTable;
}
for (; (infoPtr != NULL) && (infoPtr->type != TK_ARGV_END);
suggested patch