View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 0000318 | 1003.1(2004)/Issue 6 | System Interfaces | public | 2010-09-17 08:45 | 2013-04-16 13:06 |
| Reporter | ajosey | Assigned To | ajosey | ||
| Priority | normal | Severity | Objection | Type | Clarification Requested |
| Status | Closed | Resolution | Accepted | ||
| Name | Andrew Josey | ||||
| Organization | The Open Group | ||||
| User Reference | XSHbug2.txt Enhancement Request Number 248 | ||||
| Section | getopt | ||||
| Page Number | 541 | ||||
| Line Number | 17820 | ||||
| Interp Status | --- | ||||
| Final Accepted Text | |||||
| Summary | 0000318: getopt() does not give any significance to a value of zero for optind | ||||
| Description | The description of getopt() does not give any significance to a value of zero for optind. It just says "The variable optind is the index of the next element of the argv[] vector to be processed. It shall be initialized to 1 by the system, and getopt() shall update it when it finishes with each element of argv[]." Based on this, an application writer might expect that if they have an argument vector consisting just of options and operands (i.e. no utility name or equivalent in argv[0]), then they should be able to use getopt() to process this vector from the beginning by setting optind to zero before the first call. However, in practice this is not portable because some implementations treat an optind value of zero in a special way. (According to Michael Kerrisk, for the glibc getopt() an optind of zero causes a reinitialisation of extended features. Resetting it to 1 in order to scan a new vector only works if extensions are not used. BSD apparently treats an optind of zero as a reset for compatibility with glibc.) Either the POSIX description should be updated to say that if optind is zero the behaviour is unspecified, or the rationale should be updated to say that treating an optind of zero as special is not conforming. The action below does the former. | ||||
| Desired Action | On line 17820 after "and getopt() shall update it when it finishes with each element of argv[]", add a new sentence: "If the application sets optind to zero before calling getopt(), the behavior is unspecified." | ||||
| Tags | tc1-2008 | ||||
| Date Modified | Username | Field | Change |
|---|---|---|---|
| 2010-09-17 08:45 | ajosey | New Issue | |
| 2010-09-17 08:45 | ajosey | Status | New => Under Review |
| 2010-09-17 08:45 | ajosey | Assigned To | => ajosey |
| 2010-09-17 08:45 | ajosey | Name | => Andrew Josey |
| 2010-09-17 08:45 | ajosey | Organization | => The Open Group |
| 2010-09-17 08:45 | ajosey | User Reference | => XSHbug2.txt Enhancement Request Number 248 |
| 2010-09-17 08:45 | ajosey | Section | => getopt |
| 2010-09-17 08:45 | ajosey | Page Number | => 541 |
| 2010-09-17 08:45 | ajosey | Line Number | => 17820 |
| 2010-09-17 08:45 | ajosey | Interp Status | => --- |
| 2010-09-17 08:46 | ajosey | Status | Under Review => Resolved |
| 2010-09-17 08:46 | ajosey | Resolution | Open => Accepted |
| 2010-09-17 08:46 | ajosey | Tag Attached: tc1-2008 | |
| 2013-04-16 13:06 | ajosey | Status | Resolved => Closed |