Output of process substitution in bash duplicates ^A characters

Yes, the \x01 is duplicated when used inside parameter expansion:

$ cat -v <(echo $'\x01')
^A^A

And it happens in versions of bash after 2.05:

$ ./script
zsh/sh          : ^A
b203sh          : ^A
b204sh          : ^A
b205sh          : ^A
b30sh           : ^A^A
b32sh           : ^A^A
b41sh           : ^A^A
b42sh           : ^A^A
b43sh           : ^A^A
b44sh           : ^A^A
ksh93           : ^A
attsh           : ^A
zsh/ksh         : ^A
zsh             : ^A

That doesn't happen in a pipe:

$ echo $'\x01' | cat -v
^A

Workaround:

So, maybe you can re-write your code to:

$ echo $'\x01' | some-command

Or:

$ some-command <(sed $'s\x02foo\x02bar\x02g' some-file)

Tags:

Bash