Tcl Library Source Code

View Ticket
Login
Ticket UUID: 1473699
Title: -? and -help broken
Type: Bug Version: None
Submitter: nobody Created on: 2006-04-20 17:04:07
Subsystem: cmdline Assigned To: andreas_kupries
Priority: 5 Medium Severity:
Status: Closed Last Modified: 2026-11-21 11:06:48
Resolution: By Design Closed By: serhiy.storchaka
    Closed on: 2026-11-21 11:06:48
Description:
cmdline lists the Options -? and -help per default but
they doesn't work with the dash.

Example Script:
#!/bin/sh
#\
exec tclsh "$0" "$@"
#
package require cmdline
#
set options {
   {h              "print this message"}
}
#
# set usage string
set usage ": name \[options\] \[value\]"
#
# parse commandline arguments into array
array set cmdopt [::cmdline::getoptions argv $options
$usage]
#
#EoF

Gives errors:
./example_script.tcl -?
./example_script.tcl -help

Works as expected:
./example_script.tcl ?
./example_script.tcl help
User Comments: serhiy.storchaka added on 2026-11-21 11:06:48:

-? and -help deliver the usage text as an error with errorcode {CMDLINE USAGE}; trap it as in the manpage example. ? and help without a dash are ordinary arguments.