getopt(1) doesn't/can't preserve quoted args
ptw at babel.UUCP
ptw at babel.UUCP
Tue Feb 18 03:07:59 AEST 1986
As described in the man page, getopt(1) will erroneously be passed arguments
if any contain embedded IFS characters. The correct invocation of getopt
should be:
set -- `getopt <optstring> "$@"`
to preserve quoted args. Unfortunately, getopt itself does not preserve
quoting. The only "legitimate" way I could think of enhancing getopt to
preserve quoted args would be for it to single-quote each element of
its output string, requiring the following usage:
eval set -- `getopt <optstring> "$@"`
Perhaps the re-quoting could be triggered by a quote char in optstring.
Q: Does anyone use getopt? Have they run into this problem? Can anyone
suggest a better solution?
More information about the Net.bugs.usg
mailing list