getopt(1) doesn't/can't preserve quoted args
Doug Gwyn
gwyn at brl-smoke.ARPA
Mon Mar 3 17:39:12 AEST 1986
In a paper entitled "An Enhanced Getopt", T. C. Jones and L. A. Kennedy
of AT&T Bell Laboratories undertook an overhaul of getopt(1) and getopt(3C)
to support the Command Syntax Standard. They proposed altering the usage
of getopt(1) from the current
set -- `getopt ops $*`
to
eval set -- "`getopt ops "$@"`"
in order to avoid the extra IFS argument splitting. In order for this
proposal to work, a shell bug (handing of $@ when no arguments exist)
needs to be fixed.
Their proposal has one serious design botch, however: The new form of
getopt(1) cannot be upward-compatible with the current version! This
should be avoided by calling the new utility something like "getopts"
while continuing to provide a "getopt" with the old semantics during a
transition period. I hope this mistake is fixed before we all end up
having our existing shell scripts break on "flag day".
More information about the Net.bugs.usg
mailing list