Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adb-sync seems to close standard input? #38

Open
ropery opened this issue Mar 10, 2019 · 3 comments
Open

adb-sync seems to close standard input? #38

ropery opened this issue Mar 10, 2019 · 3 comments

Comments

@ropery
Copy link

ropery commented Mar 10, 2019

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.

@divVerent
Copy link
Contributor

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.

@Jarival
Copy link

Jarival commented Jul 18, 2021

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 !

@divVerent
Copy link
Contributor

divVerent commented Jul 18, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants