Boost logo

Boost-Build :

From: Chambers, Matthew (matt.chambers42_at_[hidden])
Date: 2020-09-23 15:01:19


>> -----Original Message-----
>> From: Boost-build<boost-build-bounces_at_[hidden]> On Behalf Of Chambers, Matthew via Boost-
>> build
>> Sent: 10 September 2020 15:34
>> To: Boost.Build developer's and user's list<boost-build_at_[hidden]>
>> Cc: Chambers, Matthew<matt.chambers42_at_[hidden]>
>> Subject: [Boost-build] Percent signs in Windows paths
>>
>> I'm trying to pass a filename with a % in it to a run target and running into an issue with the %
>> disappearing because of Windows cmd processing. If I double up the % in the run target, just like I
>> would in a Windows batch file, it works. Should Boost.Build handle this automatically?
> Do you need to escape the % ??
>
> rule escape ( string : symbols : escape-symbol )
>
> Escapes all of the characters in symbols using the escape symbol escape-symbol for the given string, and returns the escaped string.
>
> https://boostorg.github.io/build/manual/develop/index.html
>
> But as ever no example given to make this clear
>
> Might help?
>
> Paul

Here's an example:

Jamroot.jam:
import testing ; run a.cpp : arg1%one arg2%%two "arg3%three" "arg4%%four" ;

a.cpp:
#include <iostream>

int main(int argc, char** argv)
{
 Â Â Â  for (int i=1; i < argc; ++i)
 Â Â Â      std::cout << argv[i] << std::endl;
 Â Â Â  return 0;
}

The actions script generated from this contains:
"bin\a.test\msvc-14.1\debug\threading-multi\a.exe" one two arg1%one arg2%%two arg3%three arg4%%four

The output is:
arg1three
arg4%four

As you can see, everything between arg1 and three (%one arg2%%two arg3%) is being dropped because it's between 2 unescaped percent signs so
the Windows command processor interprets it as a variable.

If the actions script instead contains:
"bin\a.test\msvc-14.1\debug\threading-multi\a.exe" "arg1%one" "arg2%%two" "arg3%three" "arg4%%four"

The output is:
arg1%one
arg2%%two
arg3%three
arg4%%four

Which seems much more desirable. Is there any reason not to always quote those arguments? Maybe it would break some users that are depending
on this OS-specific behavior, though.

Thanks,
-Matt


Boost-Build list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk