I'm porting a Linux script to Windows & MinGW, which accesses the Android phone through ADB.
Sometime I need to pass the Android's file path as ADB command line option.
However, when invoking the ADB.exe, MinGW translates it to Windows' path.
For example,
adb shell cat /proc/version
Is translated as follows, resulting "No such file or directory" error in Android.
adb shell cat C:/Program Files (x86)/Git/proc/version
I found double-quotation helps to prevent that.
adb shell "cat /proc/version"
But is there any global siwtches or env variables to prevent MinGW for this converstion ?
The MinGW I'm using came with the "Git for Windows" package.
EDITED : I also hit another scnario, I cannot work-around with the double quotation.
$ adb push test1.mp3 /data
failed to copy 'test1.mp3' to 'C:/Program Files (x86)/Git/data': No such file or directory
$ adb push test1.mp3 "/data"
failed to copy 'test1.mp3' to 'C:/Program Files (x86)/Git/data': No such file or directory
Just found starting the double-slash is the charm.
https://web.archive.org/web/20201112005258/http://www.mingw.org/wiki/Posix_path_conversion
An argument starting with 2 or more
/
is considered an escaped Windows style switch and will be passed with the leading/
removed and all\
changed to/
.Except that if there is a
/
following the leading block of/
, the argument is considered to be a UNC path and the leading/
is not removed.| Argument from MSYS program | Sent to native Windows program as | Sent to native Windows program as | //foobar | /foobar | double / prevents conversion | //foo\bar | /foo/bar | \ converted to / | //foo/bar | //foo/bar | interpreted as UNC path, leading / not removed
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With