How to "passthrough" a file from PC to Android and back using 'exec-in' and 'exec-out' directives?
My post is more a comment than an answer (but I cannot comment).
All my comments below address only the case of Windows adb host.
adb shell gzip &gt;C:\test.gz &lt;C:\test.txt probably works just because the input file is a text file.
adb shell gzip &gt;C:\test.gz &lt;C:\test.bin fails because the call of Windows read function in adb stops reading as soon as 0x1A byte (ctrl+Z) is read. This is the default text operation mode of the Windows read function.
The workaround uses by exec-in and exec-out is to call _setmode() to configure the writing and reading of file descriptors in binary mode.
Unfortunately most of the time &lt;test.bin adb exec-in &quot;cat - &gt; sdcard/test.bin&quot; fails as well for adbd version &lt; 1.0.41 (ie anything below android 10). The cause is probably some race condition issues in the usb.cpp code of adbd.
Android 10 fixes this with the nonblocking FFS implementation and &lt;test.bin adb exec-in &quot;cat - &gt; sdcard/test.bin&quot; works with Windows (tested with LineageOS 17.1 + Windows 10)