Search code examples
bashiconv

Process substitution not working for input files with iconv


Running this in bash.

As I read the man page for iconv it accepts multiple input files hence

The cat in

iconv --from-code ISO_8859-1 --to-code UTF8 <( cat <(sed  '/^KEYWORD INTERFACE/,$d' actors.list)  <(sed  '/^KEYWORD INTERFACE/,$d' actresses.list)  <(sed  '/^KEYWORD INTERFACE/,$d' directors.list)) 

should not be necessary but if I don't have it there it only data from the actors.list file appears in the output.


Solution

  • It is certainly a bug in the iconv which is distributed with glibc. The bug is triggered by providing more than one non-mmapable command line input.

    The simplest workaround is to provide a single input by putting the invocations of sed into a single command substitution:

    iconv --from-code ISO_8859-1 --to-code UTF8 \
          <(sed  '/^KEYWORD INTERFACE/,$d' actors.list
            sed  '/^KEYWORD INTERFACE/,$d' actresses.list
            sed  '/^KEYWORD INTERFACE/,$d' directors.list)
    

    In this particular case, you could just use one sed command:

    iconv --from-code ISO_8859-1 --to-code UTF8 \
          <(sed  '/^KEYWORD INTERFACE/,$d' \
                 actors.list actresses.list directors.list)
    

    Of course, you could also insert a redundant cat as in the OP.


    Bug reported to glibc as https://sourceware.org/bugzilla/show_bug.cgi?id=17703