Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

calling batch file with semicolon in parameters from cygwin

I need to call a batch file from inside CYGWIN however one of it's parameters is a path-like string containing semicolons. Normally in windows command line one could enclose that parameter in quotes (which would need to be trimmed later on). However this approach doesn't wok in cygwin

Example batch (echoes first 3 parameters)

echo %1 
echo %2
echo %3

Windows cmd call

file.bat "a;b"  c 

Ouput

 "a;b"
 c
 empty

Cygwin call

 ./file.bat "a;b" c

Output

 a
 b
 c
like image 515
pseudo Avatar asked Feb 15 '23 21:02

pseudo


1 Answers

Including space anywhere inside quotes will ensure that parameter with semicolon or comma is passed correctly. Although I have to admit that I do not understand this behavior whatsoever, it seems to be working flawlessly.

./file.bat "a;b " c

Output

"a;b"
c

As @jeb mentioned in his comment, enclosing quotes can be trimmed by accessing parameter variable like this

 %~1 
like image 165
pseudo Avatar answered Feb 18 '23 10:02

pseudo