Greetings, Christian Franke via Cygwin!

> Andrey Repin via Cygwin wrote:
>> I'm using a wrapper script to comfortably start VS Code from file manager.
>>
>> The last line of it is
>>
>> cygstart --hide -- "/proc/cygdrive/c/Program Files/Microsoft VS 
>> Code/bin/code.cmd" "$(cygpath -alw "$_arg")"
>>
>> It works well up to the point where there are no spaces in the $_arg. But on
>> the first seen space it break the arguments list into pieces.
>> I have to double-quote the argument to maintain the consistency, like
>>
>> cygstart --hide -- "/proc/cygdrive/c/Program Files/Microsoft VS 
>> Code/bin/code.cmd" "\"$(cygpath -alw "$_arg")\""
>>
>> but that's a questionable solution at best.

> This is as expected. Unlike Cygwin's exec() emulation, cygstart does not
> add any quoting during conversion of the argv[] array to the plain argument
> string required for Windows process creation API.

Which is rather surprising, considering I've had these scripts for years.
Guess I was just TOO lucky to not stumble upon the issue sooner.

> Example:

> $ cat test.cmd
> @echo off
> echo %%1 = '%1'>test.txt
> echo %%2 = '%2'>>test.txt
> echo %%3 = '%3'>>test.txt
> echo %%4 = '%4'>>test.txt
> echo %%5 = '%5'>>test.txt

> $ ./test.cmd ArgOne 'Arg Two' 'Arg    Three'; cat test.txt
> %1 = 'ArgOne'
> %2 = '"Arg Two"'
> %3 = '"Arg    Three"'
> %4 = ''
> %5 = ''

> $ cygstart ./test.cmd ArgOne 'Arg Two' 'Arg    Three';\
>    sleep 1; cat test.txt
> %1 = 'ArgOne'
> %2 = 'arg'
> %3 = 'Two'
> %4 = 'Arg'
> %5 = 'Three'

> $ cygstart ./test.cmd ArgOne '"Arg Two"' '"Arg    Three"' ;\
>    sleep 1; cat test.txt
> %1 = 'ArgOne'
> %2 = '"Arg Two"'
> %3 = '"Arg    Three"'
> %4 = ''
> %5 = ''

> $ cygstart ./test.cmd 'ArgOne "Arg Two" "Arg    Three"' ;\
>    sleep 1; cat test.txt
> %1 = 'ArgOne'
> %2 = '"Arg Two"'
> %3 = '"Arg    Three"'
> %4 = ''
> %5 = ''


-- 
With best regards,
Andrey Repin
Monday, December 15, 2025 14:05:03

Sorry for my terrible english...

-- 
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple

Reply via email to