When converting mp3 to wav (probably in other cases, too), sox ends with exit code 0.
Despite the error "writing output file: No space left on device"
SoX v14.3.2
gcc: 4.2.1 (Apple Inc. build 5574)
arch: 1248 48 44 L
mac/sox FAIL sox: `/Volumes/NO NAME/dummy.wav' error writing output file: No space left on device
mac/sox DBUG wav: Finished writing Wave file, 0 data bytes 0 samples
As this is also happening in 14.4.0, here is a proposed fix.
What it does: Remember if during process() a SOX_EOF occurs, and change the exit code to 1 in case of an earlier SOX_EOF. There might be a better exit code to return, and this has not been tested for side effects. (multiple file processing, etc.)
However, maybe one of you devs has the big picture. I've just been looking into this for an hour and may be totally off track.
Here's my diff of sox.c:
<code>
2989c2989,2990
< while (process() != SOX_EOF && !user_abort && current_input < input_count)
---
> int lastProcessResult = SOX_SUCCESS;
> while ( 1 )
2991,2994c2992,2993
< if (advance_eff_chain() == SOX_EOF)
< break;
<
< if (!save_output_eff)
---
> lastProcessResult = process();
> if( lastProcessResult != SOX_EOF && !user_abort && current_input < input_count )
2996,2998c2995,3006
< sox_close(ofile->ft);
< ofile->ft = NULL;
< }
---
> if (advance_eff_chain() == SOX_EOF)
> break;
>
> if (!save_output_eff)
> {
> sox_close(ofile->ft);
> ofile->ft = NULL;
> }
> }
> else
> break;
>
3032c3040,3043
<
---
>
> if( lastProcessResult == SOX_EOF )
> return 1;
>
</code>