Search code examples
sedperforcep4v

Perforce triggers objecting to syntax (validation failed: sed: -e expression#1 char 16: unterminated `s' command)


I'm currently encountering an issue with p4 where a trigger to change the default text of a change list commit is throwing: 'patchnotes01' validation failed: sed: -e expression#1 char 16: unterminated `s' command

The command in question being added to triggers:

Triggers: patchnotes01 form-out change "sed -i s/<.*>/<Internal Notes>:\n\n<**External Notes**>:/ %formfile%"

Even a much more straight forward case:

Triggers: patchnotes01 form-out change "sed -i s/<.*>/<Internal Notes>:/ %formfile%"

yields the same issues/error.

I'm not entirely sure what its objecting to as the sed expression is valid. Ive used Setting up Default Description Template on P4 Client as my guide since the Helix documentation was lacking for a direct example.

The expectation was that the default commit message of <enter description>

is changed to

<Internal Notes>:

<**External Notes**>:

EDIT (Additional info):

Ive managed to get it to a point where it doesnt error out BUT any attempt to use single quotes to specify the substitution like

patchnotes01 form-out change "sed -i 's/<.*>/<Internal Notes>:<External Notes>:/' %formfile%"

Will fail with validation failed: sed: -e expression #1, char 15: unterminated address regex

Any attempt to use \n (or any \character) for a new line will yield validation failed: sed: -e expression#1 char 16: unterminated `s' command

HOWEVER: patchnotes01 form-out change "sed -i s/<.*>/<Internal Notes>:<External Notes>:/ %formfile%"

will return fine albeit, suboptimal as

<Internal_Notes>:<External_Notes>:

Which is lacking the newline for readability.

Any advice?


Solution

  • Apparently there is a solution that is convoluted but works. \n can be use IF and ONLY IF the regex substitution expression is:

    1. Surrounded by %quote%
    2. there are spaces around the \n character

    Example of what finally worked:

    patchnotes01 form-out change "sed -iE %quote%s/<.*>/[Internal_Notes]: \n\n [External_Notes]: /%quote% %formfile%"

    Any other permutation will fail when trying to use \ characters with a nonhelpful:

    Error parsing form text; check form-out triggers?
    Error detected at line 30.
    Unknown field name '[External_Notes]'.