[net.unix] CR defeat

keller%brl@sri-unix.UUCP (11/17/83)

From:      George Keller (IBD) <keller@brl>

When UNIX sends a file to the "standard output", it adds a CR to each
LF (0DH added to each 0AH).  I'd like to defeat that feature sometimes,
either with a shell command or preferably a command in the program that
is transferring the file to my terminal.  Any suggestions?

George

ron%brl-vgr@sri-unix.UUCP (11/18/83)

From:      Ron Natalie <ron@brl-vgr>

It's not the standard output that has the NL -> CRLF mapping it
is the terminal output.  To disable this feature from the shell
type "stty nl" and type "stty -nl" to restore it.  To disable it
from a program you must use the appropriate IOCTL or STTY for
your particular version of UNIX and clear the CRMOD bit.  Information
is available in the STTY(II) or TTY(IV) section of your UNIX manual.

-Ron

gwyn%brl-vld@sri-unix.UUCP (11/18/83)

From:      Doug Gwyn (VLD/VMB) <gwyn@brl-vld>

You have not described the system behavior correctly.  The only time
a CR is supplied before a newline (LF) is when the output is via the
terminal driver and the appropriate ioctl bit is on.  On older UNIXes,
this was coupled to the input mapping of CR to newline, using the
CRMOD bit in the sg_flags member of the sgttyb struct; on newer UNIXes,
input and output CR,LF handling are separately available by flag bits
in the termio struct.

For example, on UNIX System V (or, in your case, the BRL emulation
thereof) the following C routine will turn off the CR before LF, and
a similar routine would turn it on.  You can also do this with the
"stty" command if you need it in a shell script.

#include	<stdio.h>
#include	<termio.h>

NoCR()				/* disables CR before LF on stdout */
	{
	struct termio	tbuf;

	if ( ioctl( fileno( stdout ), TCGETA, (int)&tbuf ) == 0 )
		{
		tbuf.c_oflag &= ~ONLCR;
		(void)ioctl( fileno( stdout ), TCSETAW, (int)&tbuf );
		}
	}

clark.wbst@PARC-MAXC.ARPA (11/18/83)

Raw mode will do it... Perhaps someonw more wizardly can say if Raw mode eats
the machine on output; I would like to know that.  If so, something else may do
it too... Read the stty manual page.

--Ray

jlh%amsaa@sri-unix.UUCP (11/18/83)

From:      John Halliburton (SSAO) <jlh@amsaa>

g