Project

General

Profile

Actions

Bug #449

open

getopt_long_only(3c) return wrong value

Added by Jason King almost 13 years ago. Updated almost 12 years ago.

Status:
New
Priority:
Normal
Assignee:
Category:
lib - userland libraries
Start date:
2010-12-05
Due date:
% Done:

0%

Estimated time:
Difficulty:
Medium
Tags:
needs-triage
Gerrit CR:
External Bug:

Description

Copy of Opensolaris bug 6835846.

getopt_long_only() should be returning the option currently being processed, however, at least in some cases, it's returning other letters:

To test:
cc -o getopt_long_test getopt_long_test.c
./getopt_long_test -lc foo (works)
./getopt_long_test -cl foo (fails)
Expected Result
Expect it to output 'Option: X' corresponding to each option
Actual Result
In test case, using "-cl" causes it to return 'F'


Files

getopt_long_test.c (1.7 KB) getopt_long_test.c Test case from bug Jason King, 2010-12-05 09:42 PM
Actions #1

Updated by Yuri Pankov almost 12 years ago

  • Difficulty set to Medium
  • Tags set to needs-triage

Same is true for getopt_long - if specified long-style option matches the same length part of defined long-style option, it is accepted.. i.e. my changes to sed make it accept --in-place[=SUFFIX], but getopt_long will accept just --in=.bak..... The fix should be as simple as just checking that both have the same length here http://src.illumos.org/source/xref/illumos-gate/usr/src/lib/libc/port/gen/getopt_long.c#334

Actions

Also available in: Atom PDF