View Issue Details

IDProjectCategoryView StatusLast Update
00019701003.1(2013)/Issue7+TC1Shell and Utilitiespublic2026-03-03 16:19
Reporterstephane Assigned To 
PrioritynormalSeverityEditorialTypeClarification Requested
Status NewResolutionOpen 
NameStephane Chazelas
Organization
User Reference
Sectioniconv utility
Page Number(page or range of pages)
Line Number(Line or range of lines)
Interp Status
Final Accepted Text
Summary0001970: exit status unclear for iconv -c on invalid input
DescriptionThe 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 ActionMaybe change the exit status section to:

>0 An error occurred or would have occurred in the absence of -c.
TagsNo tags attached.

Activities

msbrown

2026-03-03 16:19

manager   bugnote:0007380

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?

Issue History

Date Modified Username Field Change
2026-01-22 07:39 stephane New Issue
2026-03-03 16:19 msbrown Note Added: 0007380