I really dont understand why this is happening, bash seems to remove commands while running in a while
loop.
I have the following script:
adb shell ls /foo/bar | while read file
do
folder="/foo/bar/$file"
adb pull $folder download
done
when i run the command seperatly, it works great. But wen i run it like this, i get the following output:
' does not existfoo/bar/filesdfsdf.sdf
for every file in /foo/bar.
SO i tried to give me the command back as string, i changed to echo "adb pull $folder download"
and got the following output:
download/foo/bar/fileasdfs.sdf
for each line. It seems that bash does something with the string and replaces some stuff here...
If i use '
, so no bash replacement would occur, i get the correct output.
whats happening here?
EDIT: I figured out that not while
is directly broken, its the adb shell
command what echoes a CRLF on every line end. if i use
adb shell ls /foo/bar | tr -d '\015' | while read file
do
folder="/foo/bar/$file"
adb pull $folder download
done
it works! But why is bash so allergic to CRLF? And why its deletes comnmands?