Percent signs in Windows paths

Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Percent signs in Windows paths

Boost - Build mailing list
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?
_______________________________________________
Unsubscribe & other changes: https://lists.boost.org/mailman/listinfo.cgi/boost-build
Reply | Threaded
Open this post in threaded view
|

Re: Percent signs in Windows paths

Boost - Build mailing list
> -----Original Message-----
> From: Boost-build <[hidden email]> On Behalf Of Chambers, Matthew via Boost-
> build
> Sent: 10 September 2020 15:34
> To: Boost.Build developer's and user's list <[hidden email]>
> Cc: Chambers, Matthew <[hidden email]>
> 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


_______________________________________________
Unsubscribe & other changes: https://lists.boost.org/mailman/listinfo.cgi/boost-build
Reply | Threaded
Open this post in threaded view
|

Re: Percent signs in Windows paths

Boost - Build mailing list
In reply to this post by Boost - Build mailing list
On 9/10/2020 10:34 AM, Chambers, Matthew via Boost-build wrote:
> 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?

If you put double quotes around any string(s) you pass to Boost Build it
will automatically remove those quotes internally, while your OS command
processor will not normally consider special characters within double
quotes.


_______________________________________________
Unsubscribe & other changes: https://lists.boost.org/mailman/listinfo.cgi/boost-build
Reply | Threaded
Open this post in threaded view
|

Re: Percent signs in Windows paths

Boost - Build mailing list

>> -----Original Message-----
>> From: Boost-build<[hidden email]>  On Behalf Of Chambers, Matthew via Boost-
>> build
>> Sent: 10 September 2020 15:34
>> To: Boost.Build developer's and user's list<[hidden email]>
>> Cc: Chambers, Matthew<[hidden email]>
>> 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



_______________________________________________
Unsubscribe & other changes: https://lists.boost.org/mailman/listinfo.cgi/boost-build