bmatzelle / gow

Unix command line utilities installer for Windows.
https://github.com/bmatzelle/gow/wiki
6.55k stars 363 forks source link

Unix to Windows path translation may corrupt command switches/arguments #244

Open vovcacik opened 6 years ago

vovcacik commented 6 years ago

Hi, there seems to be some kind of path translation when I call Windows program from inside bash. The translation does /c to C:\ translation so the Windows program can understand the unix mount path.

So far so good, however the translation may also be applied on places where it is not appropriate. For example cmd /c "echo foobar" is actually executed as c:\Windows\system32\cmd.exe c:/ "echo foobar".

Full example:

X:\.gow\bin>bash --version
GNU bash, version 3.1.17(1)-release (i686-pc-msys)
Copyright (C) 2005 Free Software Foundation, Inc.

X:\.gow\bin>bash
bash-3.1$ cmd /c "echo foobar"
Microsoft Windows [Version 10.0.14393]
(c) 2016 Microsoft Corporation. All rights reserved.

X:\.gow\bin>exit                                         <-- no echo executed and I had to manually exit, i.e. /c is not honored
bash-3.1$ cmd //c "echo foobar"
foobar                                                   <-- all good here, after cmd's echo a bash prompt returns
bash-3.1$ exit
exit

X:\.gow\bin>
correct command, unwanted result

bash-3.1$ cmd /c "echo foobar" = c:\Windows\system32\cmd.exe c:/ "echo foobar"

incorrect command, wanted result

bash-3.1$ cmd //c "echo foobar" = c:\Windows\system32\cmd.exe /c "echo foobar"

Note how adding syntactic error //c yields desired command call. Is this expected behaviour? I would not expect / to be escape character here. In bash it usually is \ and in Windows it is ^.

Is the workaround safe to use?