From: kkont AT estia DOT iit DOT nrcps DOT ariadne-t DOT gr (Kimon Kontovasilis) Subject: Re: Consistent mode of file-opens 11 Oct 1997 00:50:47 -0700 Message-ID: <9710101157.AA04054.cygnus.gnu-win32@estia.iit.nrcps.ariadne-t.gr> References: <19971009191302 DOT 24151 DOT qmail AT hotmail DOT com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit To: earnie_boyd AT hotmail DOT com (Earnie Boyd) Cc: gnu-win32 AT cygnus DOT com > >From: kkont AT estia DOT iit DOT nrcps DOT ariadne-t DOT gr (Kimon Kontovasilis) > >Subject: Re: Consistent mode of file-opens > >To: earnie_boyd AT hotmail DOT com (Earnie Boyd) > >Date: Thu, 9 Oct 1997 17:09:16 +0200 (EET) > >Cc: gnu-win32 AT cygnus DOT com > ---snip--- > >I guess this renders obsolete most of my original message. However, > since > >all individual utilities work adequately well with the other > dos-oriented > >shells and since all the shells that I know of support redirection and > >(simulated) pipes, it would be nice if the proper file mode selection > worked > >on these shells too. > > > > I believe that the redirection file modes are controlled by the shells > themselves. > > - \\||// > ---o0O0--Earnie--0O0o---- > -earnie_boyd AT hotmail DOT com- > ------ooo0O--O0ooo------- > Well, that's not true, at least for the "standard" MS-DOS based shells. The following are happening on a drive mounted -b (so that e.g., od reports all bytes in files). The shell in use is 4DOS.COM (same results occur with COMMAND.COM), on a Win95 machine. c:\tmp\gcc-trials> cat chkdos.c #include #include #include int main(int argc, char *argv[]) { char *test_str = "A test line\nAnother line\n"; if (argc > 1 && strcmp(argv[1], "-b") == 0) _setmode(1, O_BINARY); printf("%s", test_str); exit(0); } c:\tmp\gcc-trials> gcc chkdos.c -o chkdos c:\tmp\gcc-trials> chkdos A test line Another line c:\tmp\gcc-trials> chkdos -b A test line Another line c:\tmp\gcc-trials> chkdos > a c:\tmp\gcc-trials> od -c a 0000000 A t e s t l i n e \r \n A n o 0000020 t h e r l i n e \r \n 0000033 c:\tmp\gcc-trials> chkdos -b > a c:\tmp\gcc-trials> od -c a 0000000 A t e s t l i n e \n A n o t 0000020 h e r l i n e \n 0000031 The above show that 4DOS and COMMAND do not alter the file mode when redirecting. In contrast, as you remarked, bash does change things, so as to assure the right mode. c:\tmp\gcc-trials> bash -c "chkdos" A test line Another line c:\tmp\gcc-trials> bash -c "chkdos -b" A test line Another line c:\tmp\gcc-trials> bash -c "chkdos > a; od -c a" 0000000 A t e s t l i n e \n A n o t 0000020 h e r l i n e \n 0000031 c:\tmp\gcc-trials> bash -c "chkdos -b > a; od -c a" 0000000 A t e s t l i n e \n A n o t 0000020 h e r l i n e \n 0000031 It appeards, that the DOS-based shells take an approach similar to globbing: "let the program do it itself". Ugly and silly, I know, but a fact of life. That's why I proposed the startup code hack, in an attempt to try to remedy the problem in the same way it is done with globbing. Best regards, Kimon Kontovasilis, NCSR "Demokritos" - For help on using this list (especially unsubscribing), send a message to "gnu-win32-request AT cygnus DOT com" with one line of text: "help".