adb-sync
adb-sync copied to clipboard
adb-sync seems to close standard input?
foo
(containing file 1.txt
) and bar
(containing file 2.txt
) are two directories under /sdcard
on my phone.
When I run the following script test.sh
on my computer:
#!/bin/sh
while read -r dir; do
./adb-sync -R /sdcard/"$dir" .
done <<EOF
foo
bar
EOF
The result is that only the first directory foo
is synced:
$ ./test.sh
INFO:root:Sync: local b'./foo', remote b'/sdcard/foo'
INFO:root:Scanning and diffing...
INFO:root:Pull: b'./foo'
INFO:root:Pull: b'./foo/1.txt'
[100%] /sdcard/foo/1.txt
INFO:root:Total: 1 KB/s (312 bytes in 0.225s)
The problem is read -r dir
fails in the second iteration, perhaps implying stdin in closed.
Interesting issue.
This is probably because adb-sync calls "adb shell", which in turn connects stdin to the phone.
I think I can fix this by making adb-sync not connect stdin to its subprocesses anymore.
I face a similar problem : the directories I want to sync are listed in a CSV file 'file.csv' (2 fields on each line : SOURCE,DEST).
When I run the bash script #!/bin/bash while read line; do ./adb-sync $SOURCE $DEST done < file.csv
only the first line of file.csv is read and consequently, only the first directory is synced.
I've found a workaround. Instead of a 'while... do... done' loop, I use a 'for... do... done' loop.
#!/bin/bash for line in $(cat file.csv); do ./adb-sync $SOURCE $DEST done
It works fine, but I couldn't explain why !
Pretty sure it is not adb-sync but adb that eats standard input, so I suggest filing a bug against adb. We could work around it in adb-sync but it would probably be preferred to fix adb.
Having said that, as a workaround you can also use
adb-sync ... </dev/null
in your scripts.
On Sun, Jul 18, 2021, 05:23 Jarival @.***> wrote:
I face a similar problem : the directories I want to sync are listed in a CSV file 'file.csv' (2 fields on each line : SOURCE,DEST).
When I run the bash script #!/bin/bash while read line; do ./adb-sync $SOURCE $DEST done < file.csv
only the first line of file.csv is read and consequently, only the first directory is synced.
I've found a workaround. Instead of a 'while... do... done' loop, I use a 'for... do... done' loop.
#!/bin/bash for line in $(cat file.csv); do ./adb-sync $SOURCE $DEST done
It works fine, but I couldn't explain why !
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/google/adb-sync/issues/38#issuecomment-882027535, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAB5NMF6XBEROXSTYTCPEZ3TYKMRLANCNFSM4G44LTUA .