Calling a batch file with a semicolon in parameters from cygwin

I need to call a batch file from within CYGWIN, however one of its parameters is a path type string containing semicolons. Typically, on the Windows command line, you can enclose this parameter in quotation marks (which you will need to trim later). However this approach does not work in cygwin

Batch example (echo of the first three parameters)

echo %1 echo %2 echo %3 

Windows cmd call

 file.bat "a;b" c 

Ouput

  "a;b" c empty 

call cygwin

  ./file.bat "a;b" c 

Output

  a b c 
+4
source share
1 answer

Enabling space inside quotation marks ensures that a parameter with a semicolon or semicolon is passed correctly. Although I must admit that I do not understand this behavior, it works flawlessly.

 ./file.bat "a;b " c 

Output

 "a;b" c 

As @jeb mentioned in his comment, closing quotation marks can be truncated by accessing a parameter variable like this

  %~1 
+4
source

Source: https://habr.com/ru/post/1492317/


All Articles