This is the mail archive of the cygwin-apps@cygwin.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: ash stdin mode is set to O_TEXT


On Sun, Apr 22, 2001 at 09:25:00AM -0400, Earnie Boyd wrote:
> Corinna Vinschen wrote:
> > 
> > On Sat, Apr 21, 2001 at 01:19:57PM -0400, Christopher Faylor wrote:
> > > On Sat, Apr 21, 2001 at 08:25:56PM +0400, egor duda wrote:
> > > >ash stdin mode is set to O_TEXT, so it's impossible to checkin/chechout
> > > >binary files from cvs when CVS_RSH is sh script.
> > > >
> > > >maybe O_TEXT should be set only in interactive mode?  or shouldn't be
> > > >set at all?
> > >
> > > Corinna and I have discussed this in the past.  The problem is that the
> > > 'read' command should always be text mode whether it is interactive or
> > > not.  Also, if sh is reading a shell script via:
> > >
> > > sh < foo
> > >
> > > the input should be in O_TEXT mode.
> > >
> > > But then, if ash is reading from a pipe, stdin should, IMO, be in binary
> > > mode.
> > 
> > That's really tricky:
> > 
> >         sh < foo                O_TEXT?
> >         cat foo | sh            O_BINARY?
> > 
> 
> Correct, and from what I remember of the bash code it knows when it's
> about to read/write from/to a pipe/redirect.  Wouldn't you just use the
> appropriate setmode on the duplicated file handle?

I'm not sure if I understand you right. Do you mean sth. like that:

	struct stat s;
	fstat(STDIN_FILENO, &s);
	if (S_ISCHR(s.st_mode) || S_ISREG(s.st_mode))
	  setmode(STDIN_FILENO, O_TEXT);
	else
	  setmode(STDIN_FILENO, O_BINARY);

?

Corinna


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