This is the mail archive of the cygwin@sources.redhat.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: CR/LF and read is shell scripts



Earnie Boyd wrote:
>Let me see if IIRC.  You, Eric Fifer, had said that cat is forcing binary
mode
>file processing regardless of the text/binary mode default settings.

Yes, see textutils-2.0/src/cat.c around line 650:

  /* We always read and write in BINARY mode, since this is the
     best way to copy the files verbatim.  Exceptions are when
     they request line numbering, squeezing of empty lines or
     marking lines' ends: then we use text I/O, because otherwise
     -b, -s and -E would surprise users on DOS/Windows where a line
     with only CR-LF is an empty line.

>Cat, IIRC, comes from the textutils package.  This implies that cat is a
text
>utility and processing of files should default to text mode processing.

This is historical usage.  The usage of `cat` is pervasive, and now
simple things like this fail if foo is on a text mount:

	x=hello
	echo $x >foo
	y=`cat foo`
	if [ "$x" != "$y" ]; then echo not equal; fi

>IIRC, you had also suggested a switch --binmode for processing binary files
>with cat.

I said --binary/-B is now in the latest version of cat, look at the source.

>I believe that this should be the case.  So given this cat should be
>changed to:
>
>Process stdin in text mode and stdout in binary mode.
>Process stdin and stdout in binary mode if --binmode is given.
>Process stdin and stdout in text mode if --textmode is given.
>Process stdin in binary if --binmode-in is given.
>Process stdout in text mode if --textmode-out is given.
>The switch --textmode-in and --binmode-out should also be supported.

The default Cygwin behavior for binmode/textmode processing
should be fine.  The way cat formerly worked was correct
(I'm actually using my old B20.1 cat to work around this
problem).  The current problems were introduced by the upgrade to
textutils-2.0 cat which added some O_BINARY handling for Win32,
and at the same time clobbered the default Cygwin textmode/binmode
processing.

Eric

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]