It's all about the answers!

Ask a question

.edit and newlines


Tim McDaniel (401146) | asked Sep 07 '10, 2:35 p.m.
Build Forge Help says "Document version and build: 7.1.1.4.0.0082."

We're trying to use .edit to substitute values on a line. What we'd
like to do is

..edit /P4CLIENT=.*$/P4CLIENT=${P4CLIENT}/ ${VersionFull}/base.properties

That is, in this properties file, whatever P4CLIENT was set to,
instead force it to be set to such-and-so a value.

The problem is that the .edit command strips the line ending from the
end of the line, so the line ends up concatenated with the next line.

I have tried to follow the advice of the help and use \\\\n. I've
also tried \\n and \n. The result appears to be the same in all
cases: the step times out after the default 5 minutes, a Build Forge
agent continues running on the build machine sucking down 100% of the
CPU, and the file being edited is zero-length.

Any ideas? We can't use .strsub because we don't know what the
existing value of the line is. The team lead really really wants to
do it "the Build Forge way", but with the .edit command apparently
being useless, I don't see an alternative to Cygwin tools.

Should I enter a bug report that says that .edit should be implemented
safely: edit from a source file to a temp file (or buffer if it's
small enough), then open the source file for writing and copy the
contents of the temp storage into the source file?

--
Tim McDaniel, tmcd@panix.com

2 answers



permanent link
Brent Ulbricht (2.5k11) | answered Sep 08 '10, 10:02 a.m.
JAZZ DEVELOPER
Build Forge Help says "Document version and build: 7.1.1.4.0.0082."

We're trying to use .edit to substitute values on a line. What we'd
like to do is

..edit /P4CLIENT=.*$/P4CLIENT=${P4CLIENT}/ ${VersionFull}/base.properties

That is, in this properties file, whatever P4CLIENT was set to,
instead force it to be set to such-and-so a value.

The problem is that the .edit command strips the line ending from the
end of the line, so the line ends up concatenated with the next line.

I have tried to follow the advice of the help and use \\\\n. I've
also tried \\n and \n. The result appears to be the same in all
cases: the step times out after the default 5 minutes, a Build Forge
agent continues running on the build machine sucking down 100% of the
CPU, and the file being edited is zero-length.

Any ideas? We can't use .strsub because we don't know what the
existing value of the line is. The team lead really really wants to
do it "the Build Forge way", but with the .edit command apparently
being useless, I don't see an alternative to Cygwin tools.

Should I enter a bug report that says that .edit should be implemented
safely: edit from a source file to a temp file (or buffer if it's
small enough), then open the source file for writing and copy the
contents of the temp storage into the source file?

--
Tim McDaniel, tmcd@panix.com


Hi Tim,

The .edit command uses POSIX Extended Regular Expression syntax by default. If the agent has been compiled with Perl Compatible Regular Expression support, the substitution expression may be followed by a "p" character to specify PCRE syntax.

I'm using a Windows agent that I installed from a normal Build Forge distribution (must have been compiled with PCRE).

In trying a scenario similar to your example, I had success with the command text below. The only difference is the "p" after the substitution expression.

.edit /P4CLIENT=.*$/P4CLIENT=${P4CLIENT}/p ${VersionFull}/base.properties


bju

permanent link
Tim McDaniel (401146) | answered Sep 08 '10, 9:04 p.m.
In article <i66emo>,
Tim McDaniel <tmcd> wrote:
Build Forge Help says "Document version and build: 7.1.1.4.0.0082."
....
The problem is that the .edit command strips the line ending from the
end of the line, so the line ends up concatenated with the next line.

After posting, I looked at the file in Notepad for once, and saw that
all the lines were terminated by newlines (LF), not the Windows
standard of CR LF. If that's the problem, then I would suggest that
- .edit be changed to allow LF-terminated lines on Windows
or
- .edit be changed to treat those as single lines
And
- the documentation should specify what happens.
I'd much prefer LF-terminated lines to be treated as lines.

The rest, about backslashes in .edit lines, I have no more insights
for.

--
Tim McDaniel, tmcd@panix.com

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.