[OpenAFS-devel] Why does default_com_err_proc() spit out a carriage return?

Phillip Moore w.phillip.moore@gmail.com
Thu, 4 Nov 2010 15:30:14 -0400


--00163642715ee2ffdb04943f2fbf
Content-Type: text/plain; charset=ISO-8859-1

Does anyone know why, in src/comerr/com_err.c, in default_com_err_proc(),
the code does the following:

    putc('\n', stderr);
    /* should do this only on a tty in raw mode */
    putc('\r', stderr);
    fflush(stderr);

When you run a command which generates both normal output AND errors, you
get a mix of lines which end in a plain newline (\n) and lines which end in
both a plain newline AND a carriage return (\n\r).   When parsing that
output, code that assumes a default IRS of just \n gives you some lines
which start with the \r, and this is a potential headache for anything that
tries to parse it.

I will have to workaround this in the AFS::Command code that parses pts
output, and deal with it, but going forward, I'd really like to rip out the
extra \r.

Is there a valid reason for leaving this in place?  If not, I'll nuke it....

--00163642715ee2ffdb04943f2fbf
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

Does anyone know why, in src/comerr/com_err.c, in=A0default_com_err_proc(),=
 the code does the following:<div><br></div><div><div>=A0=A0 =A0putc(&#39;\=
n&#39;, stderr);</div><div>=A0=A0 =A0/* should do this only on a tty in raw=
 mode */</div>
<div>=A0=A0 =A0putc(&#39;\r&#39;, stderr);</div><div>=A0=A0 =A0fflush(stder=
r);</div></div><div><br></div><div>When you run a command which generates b=
oth normal output AND errors, you get a mix of lines which end in a plain n=
ewline (\n) and lines which end in both a plain newline AND a carriage retu=
rn (\n\r). =A0 When parsing that output, code that assumes a default IRS of=
 just \n gives you some lines which start with the \r, and this is a potent=
ial headache for anything that tries to parse it.</div>
<div><br></div><div>I will have to workaround this in the AFS::Command code=
 that parses pts output, and deal with it, but going forward, I&#39;d reall=
y like to rip out the extra \r.</div><div><br></div><div>Is there a valid r=
eason for leaving this in place? =A0If not, I&#39;ll nuke it....</div>

--00163642715ee2ffdb04943f2fbf--