diff options
author | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2020-05-27 22:25:10 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2020-05-27 22:25:10 +0000 |
commit | 728b1c83fa28ef2c5b0e1059c2bec27dae4e11b7 (patch) | |
tree | edd8bf03716a04cfb10cd8d88b1058480385b33d /regress/lib/libm | |
parent | f154390e02fd03feed6a2baefc5f66e2a5bdf46b (diff) |
This patch fixes one bug and one instance of undesirable behaviour.
The bug, present since 4.4BSD, was that a trailing dash in an option
group, when the dash is not permitted as an option letter, resulted
in the whole option group being returned as an argument, even though
the previous option in the group was already parsed as an option:
OPTS=abc ./getopt-test -a- -c arg ===>> OPT(a)ARG(-a-)ARG(-c)ARG(arg).
Instead, treat the dash as an invalid option and continue parsing
options: ===>> OPT(a)ERR(?-)OPT(c)ARG(arg).
The undesirable behaviour was that allowing the dash as an option
letter only allowed isolated dashes ("-") and trailing dashes in
groups ("-a-"), but neither middle dashes in groups ("-a-b"), even
though that already partially worked in 4.4BSD, nor leading dashes
in groups ("--a"), even though that works on all other BSDs and on
glibc. Also, while POSIX does not require that the dash can be
used as an option letter at all, arguably, it encourages that letters
either be fully supported or not supported at all. It is dubious
whether supporting an option letter in some positions but not in
others can be considered conforming.
This patch makes OpenBSD behaviour identical to FreeBSD and NetBSD,
improves compatibility with glibc (except that glibc does not support
isolated "-"), improves compatibility with DragonFly (except that
DragonFly is buggy when the dash option letter can take an optional
argument but that argument is not present), improves compatibility
with Illumos and Solaris 11 (except those do not support "-" and
mishandle "--a"), and restores 4.4BSD behaviour for "-a-b". In no
respect i'm aware of is compatibility with any other systems reduced.
For the full rationale, see my mail to tech@
on 30 Mar 2020 14:26:41 +0200.
Part of the problem was originally reported by an anonymous coward
on tech@ on 12 Mar 2020 03:40:24 +0200, additional analysis was
contributed by martijn@, and then the OP sent the final version of
the patch i'm now committing on 17 Mar 2020 19:17:56 +0200.
No licensing problem here because after the commit, the file does
not contain a single word written by the OP. Also, the OP told me
in private mail that he intends to publish the patch under the ISC
license already contained in the file and that he wishes to be known
by the pseudonym "0xef967c36".
OK martijn@, and no objection when shown on tech@,
but commit delayed to stay clear of the release.
Diffstat (limited to 'regress/lib/libm')
0 files changed, 0 insertions, 0 deletions