I'm looking for a way to redirect stdin and stdout to the same character device. I know I can do it manually:
rz </dev/ttyUSB0 >/dev/ttyUSB0
However, it feels repetitive. On top of that, shellcheck complains:
Make sure not to read and write the same file in the same pipeline
It's quite easy to redirect stdout and stderr to the same file (cmd >file 2>&1) but it won't work for stdin and stdout:
$ rz >/dev/ttyUSB0 <&1
rz waiting to receive.Retry 0: Got TIMEOUT
Retry 0: Got TIMEOUT
I was able to come with a solution that works in bash and dash but not in fish:
<>opens file in read-write mode. It is used as stdin.>&0redirects stdout to the file descriptor used by stdin.