public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
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	[thread overview]
Message-ID: <9710101157.AA04054@estia.iit.nrcps.ariadne-t.gr> (raw)
In-Reply-To: <19971009191302.24151.qmail@hotmail.com>

> >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 <stdio.h>
#include <string.h>
#include <fcntl.h>

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".

  reply	other threads:[~1997-10-10 15:04 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-10-09 12:13 Earnie Boyd
1997-10-10 15:04 ` Kimon Kontovasilis [this message]
  -- strict thread matches above, loose matches on Subject: below --
1997-10-10 15:04 Larry Hall
1997-10-09 16:37 dahms
1997-10-10  6:25 ` Kimon Kontovasilis
1997-10-09 15:57 Earnie Boyd
1997-10-09 16:37 ` Kimon Kontovasilis
1997-10-08 14:47 Kimon Kontovassilis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9710101157.AA04054@estia.iit.nrcps.ariadne-t.gr \
    --to=kkont@estia.iit.nrcps.ariadne-t.gr \
    --cc=earnie_boyd@hotmail.com \
    --cc=gnu-win32@cygnus.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).