Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Passing raw command-line

Dec
51
0
Hello folks.

I have this my-vcpkg.bat file for the Package Manager vcpkg.exe [1].
It is basically:
cmd.exe /C vcpkg.exe --vcpkg-root %VCPKG_ROOT %$

But sometimes I need to pass a command-line like:
my-vcpkg.bat install package-y[feature1,feature2]:x64-windows
With that, vcpkg.exe receives this as:
vcpkg.exe --vcpkg-root f:\gv\VC_project\VCPKG install package-y[feature1 feature2]:x64-windows

I.e. the comma (,) gets eaten by TCC 31.01.22. I've tried various setdos /X-y values
to no avail. How do I do this?

[1] GitHub - microsoft/vcpkg-tool: Components of microsoft/vcpkg's binary.
 
Last edited:
It is basically:

cmd.exe /C vcpkg.exe --vcpkg-root %VCPKG_ROOT %$


But using %*, it works:
cmd.exe /C vcpkg.exe --vcpkg-root %VCPKG_ROOT %*

Since I do not use any SHIFT, why is the behaviour different?
 
Last edited:
%$ treats spaces, tabs, commas, and equals signs (=) as delimiters and any of these passed within a parameter will be replaced with a space.

The individual parameter variables (%1, %2, etc) also treat the same characters as delimiters.

Within your called .BTM you may need to use %@Word with %* to process the first parameter and not %1 if the parameter contains any of those characters.
 
Parameter parsing and delimiters are described here TCC Batch File Parameters.

Behavior of %* is described on this page as "the complete command tail, unmodified by shift".

I discovered the behavior of %* with regards to delimiters and the behavior of the positional parameters (%1, %2, etc) after reviewing the functionality of the excellent GetOpt library function (written by Michael @Fross) along with a little trial and error experimenting.



1777137780600.webp
 
If you don't care about CMD compatibility, in addition to turning off the TCC option "Duplicate CMD.EXE bugs", you can set the CMDBatchDelimiters option in the INI file (4NT section) to No.
 
Back
Top