From mboxrd@z Thu Jan 1 00:00:00 1970 From: kkont@estia.iit.nrcps.ariadne-t.gr (Kimon Kontovasilis) To: earnie_boyd@hotmail.com (Earnie Boyd) Cc: gnu-win32@cygnus.com Subject: Re: Consistent mode of file-opens Date: Fri, 10 Oct 1997 15:04:00 -0000 Message-id: <9710101157.AA04054@estia.iit.nrcps.ariadne-t.gr> References: <19971009191302.24151.qmail@hotmail.com> X-SW-Source: 1997-10/msg00226.html > >From: kkont@estia.iit.nrcps.ariadne-t.gr (Kimon Kontovasilis) > >Subject: Re: Consistent mode of file-opens > >To: earnie_boyd@hotmail.com (Earnie Boyd) > >Date: Thu, 9 Oct 1997 17:09:16 +0200 (EET) > >Cc: gnu-win32@cygnus.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@hotmail.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@cygnus.com" with one line of text: "help".