bmatzelle / gow

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

when bash starts a cmd, it adds a buggy double quote symbol at the end of the line #243

Open arteika opened 6 years ago

arteika commented 6 years ago

Consider the following situation:

$ pwd
/c/tmp

$ ls
a

$ ls a
a.bat

$ cat a/a.bat
echo %*

$ cmd ". /C a\a.bat aaa"
c:\tmp>echo aaa"
aaa"

and there's a double quote at the end. Seems to be a bug?

$ gow -V
Gow 0.8.0

$ ver

Microsoft Windows [Version 10.0.16299.64]
vovcacik commented 6 years ago

This is not a bug, at least not in gow tools. I can replicate the same behaviour in vanilla cmd, without including bash:

C:\Users\Admin\AppData\Local\Temp\_test>pwd
C:\Users\Admin\AppData\Local\Temp\_test

C:\Users\Admin\AppData\Local\Temp\_test>ls
a

C:\Users\Admin\AppData\Local\Temp\_test>ls a
a.bat

C:\Users\Admin\AppData\Local\Temp\_test>cat a/a.bat
echo %*

C:\Users\Admin\AppData\Local\Temp\_test>cmd ". /C a\a.bat aaa"

C:\Users\Admin\AppData\Local\Temp\_test>echo aaa"
aaa"

The problem is in your cmd ". /C a\a.bat aaa" command which is syntactically incorrect and hence the parsing error. What I think you want is this cmd /D . /C "a\a.bat aaa", that works as expected. This works only in vanilla cmd. Docs.

arteika commented 6 years ago

Thanks a lot for the reply, the additional information how to invoke the cmd and the thumbs down.

I confirm the same behaviour using vanilla cmd. How much vanilla cmd that is, is an object of discussion as you are using commands from gow itself (e.g., pwd).

My goal is to start a bat/cmd script from bash and get back to bash. You suggested to run: cmd /D . /C "a\a.bat aaa" from bash. This starts the command as expected, howerver does not return to bash after "execution":

$ cmd /D . /C "a\a.bat aaa"
Microsoft Windows [Version 10.0.16299.64]
(c) 2017 Microsoft Corporation. All rights reserved.

c:\tmp>

How can return to bash after the execution?

vovcacik commented 6 years ago

The short answer would be $ cmd //D . //C "a\a.bat aaa". The long answer is in #244.