job000607

reg_smith (reg_smith)
reg_smith created this job , modified by Perforce maintenance
Open
P4Perl P4::MergeData::RunMergeTool, quote filename arguments to protect from shell metacharacters

Also  Perforce internal job088679 has been logged against p4api.

Using P4Perl to do a merge that uses P4::MergeData::RunMergeTool to call out to a bash script as the merge tool.

On Linux, if filenames have the shell metacharacter "(" in their names it causes bash to fail with "h: -c: line 0: syntax error near unexpected token `(' "
Other shell metacharacters would likely cause issues as well. This is expected shell behaviour and you would normally either quote a filename that contains metacharacters or escape the metacharacters.

For "(" it works on windows as "(" isn't a windows cmd shell metacharacter.

Quoting the arguments passed from RunMergeTool should escape the special meaning of any shell metacharacters.

It doesn't seem to be a P4Perl problem directly; invoking P4::MergeData::RunMergeTool, the control is handed over to the native P4.so.
Somewhere in P4.so, there's probably a call like system("mergeTool BASE THEIRS YOURS MERGED").
Perhaps that could be adjusted to allow for special characters especially in the parameters.

Currently filename args are quoted if they contain spaces which appears to be referred to in the C api that P4Perl interfaces with:
https://www.perforce.com/perforce/doc.current/manuals/p4api/index.html

include\p4\runcmd.h has the following commends on line 67/68:

*    NT: quote with " all args, and use CreateProcess()
*    UNIX: quote with ' args with spaces, and use system()
  • Details
  • Comments -
Status
Open
Project
p4perl
Severity
C
Reported By
reg_smith
Reported Date
Modified By
Perforce maintenance
Modified Date
Owned By
reg_smith
Type
Feature