View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 0001970 | 1003.1(2013)/Issue7+TC1 | Shell and Utilities | public | 2026-01-22 07:39 | 2026-03-03 16:19 |
| Reporter | stephane | Assigned To | |||
| Priority | normal | Severity | Editorial | Type | Clarification Requested |
| Status | New | Resolution | Open | ||
| Name | Stephane Chazelas | ||||
| Organization | |||||
| User Reference | |||||
| Section | iconv utility | ||||
| Page Number | (page or range of pages) | ||||
| Line Number | (Line or range of lines) | ||||
| Interp Status | |||||
| Final Accepted Text | |||||
| Summary | 0001970: exit status unclear for iconv -c on invalid input | ||||
| Description | The iconv utility specification has: > The presence or absence of -c shall not affect the exit status of iconv. Which suggests that iconv should return the same exit status with -c that it should without. But the exit status section has: > >0 > An error occurred. Which seems to be in contradiction. AFAICT, both the iconv that comes with GNU libc and GNU libiconv exit with status 1 and no error message in: printf '\303\n' | iconv -c -f UTF-8 For instance and the one from FreeBSD gives no error and exit with 0. I've not tested other implementations. BTW, all three implementations exit with 1 and report an error message when the decoding error is found at the end (like in printf '\303' | iconv -c -f UTF-8), which seems to be in breach of the POSIX specification. Not sure whether that's intentional or not. | ||||
| Desired Action | Maybe change the exit status section to: >0 An error occurred or would have occurred in the absence of -c. | ||||
| Tags | No tags attached. | ||||
|
|
We discovered that implementations have variances on how they have implemented -c, with some clearing the exit status while others do not. IMHO, the text at page 3003 line 100489 is pretty clear that the erxit status should not be cleared and here is my suggested change: To further make clear that the exit status should still be set when encountering an invalid sequence even if -c is present On page 3–5 line 100558 section iconv change: >0 An error occurred. to: >0 An error occurred, or would have occurred in the absence of -c. However, we’ve also encountered an apparent issue with diagnostic messages: on almost all implementations the messages written to STDERR are suppressed when using -c, even though the standard calls for -s to be used if messages are to be suppressed. IMHO I think that this is erroneous, and messages should not be suppressed by -c, just as exit status is not cleared. If we also want to say that diagnostic messages should not be suppressed by -c On page 3003 line 100489 section iconv change: The presence or absence of −c shall not affect the exit status of iconv. to: The presence or absence of −c shall not affect the exit status of, nor the issuance of messages written to standard error concerning invalid characters by, iconv. This latter may be better expressed as a separate MANTIS issue, for a future edition? |