# use binmode(STDOUT) in git-status

11 messages from 2005-11-28 to 2005-11-29. Participants: Alex Riesen, H. Peter Anvin, Johannes Schindelin, Junio C Hamano, Tim O'Callaghan.
Thread: https://gitlist.dev/t/2699

## Alex Riesen, 2005-11-28 07:34

Subject: use binmode(STDOUT) in git-status
Message-ID: <81b0412b0511272334w393434e7lad3e3b102e6c3e9e@mail.gmail.com>
URL: https://gitlist.dev/e/81b0412b0511272334w393434e7lad3e3b102e6c3e9e%40mail.gmail.com

```
Activision's Perl generates CRLF unless STDOUT is binmoded, which is
inconsistent with other output of git-status.

---
I assume none _sane_ can want CRLF as line-ending...


Subject: [PATCH] use binmode on STDOUT to avoid generation of CRLF by activision perl

Signed-off-by: Alex Riesen <fork0@gmail.com>


---

 git-status.sh |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

applies-to: c64901fa1a7f5fa19d025a315bcd1e5d5eae5d93
0fc9f4bdb41725d2b2b54e70ff4740bdb826bdea
diff --git a/git-status.sh b/git-status.sh
index b90ffc1..2fc7595 100755
--- a/git-status.sh
+++ b/git-status.sh
@@ -82,13 +82,14 @@ else
         --exclude-per-directory=.gitignore
 fi |
 perl -e '$/ = "\0";
+	binmode(STDOUT);
 	my $shown = 0;
 	while (<>) {
 		chomp;
 		s|\\|\\\\|g;
 		s|\t|\\t|g;
 		s|\n|\\n|g;
-		s/^/#	/;
+		s/^/#\t/;
 		if (!$shown) {
 			print "#\n# Untracked files:\n";
 			print "#   (use \"git add\" to add to commit)\n#\n";
---
0.99.9.GIT

```

## H. Peter Anvin, 2005-11-28 15:55

Subject: Re: use binmode(STDOUT) in git-status
Message-ID: <438B2859.6060109@zytor.com>
URL: https://gitlist.dev/e/438B2859.6060109%40zytor.com
In-Reply-To: <81b0412b0511272334w393434e7lad3e3b102e6c3e9e@mail.gmail.com>

```
Alex Riesen wrote:
> Activision's Perl generates CRLF unless STDOUT is binmoded, which is
> inconsistent with other output of git-status.
> 
> ---
> I assume none _sane_ can want CRLF as line-ending...

Well, if it's a text file we probably should use platform-native 
line-ending, and at least be tolerant of \r\n.

	-hpa

```

## Johannes Schindelin, 2005-11-28 16:02

Subject: Re: use binmode(STDOUT) in git-status
Message-ID: <Pine.LNX.4.63.0511281700100.11362@wbgn013.biozentrum.uni-wuerzburg.de>
URL: https://gitlist.dev/e/Pine.LNX.4.63.0511281700100.11362%40wbgn013.biozentrum.uni-wuerzburg.de
In-Reply-To: <438B2859.6060109@zytor.com>

```
Hi,

On Mon, 28 Nov 2005, H. Peter Anvin wrote:

> Alex Riesen wrote:
> > Activision's Perl generates CRLF unless STDOUT is binmoded, which is
> > inconsistent with other output of git-status.
> > 
> > ---
> > I assume none _sane_ can want CRLF as line-ending...
> 
> Well, if it's a text file we probably should use platform-native line-ending,
> and at least be tolerant of \r\n.

Of course, here is the problem: git on Windows runs only using cygwin. You 
can specify the line ending behaviour of cygwin (I think it is an env 
variable). Activision Perl, being independent of cygwin, does not care 
about that setting.

So, to be accurate, you'd have to check what *cygwin* expects, and 
depending on that execute binmode(STDOUT) or not.

Ciao,
Dscho

```

## H. Peter Anvin, 2005-11-28 16:08

Subject: Re: use binmode(STDOUT) in git-status
Message-ID: <438B2B90.9010500@zytor.com>
URL: https://gitlist.dev/e/438B2B90.9010500%40zytor.com
In-Reply-To: <Pine.LNX.4.63.0511281700100.11362@wbgn013.biozentrum.uni-wuerzburg.de>

```
Johannes Schindelin wrote:
> 
> Of course, here is the problem: git on Windows runs only using cygwin. You 
> can specify the line ending behaviour of cygwin (I think it is an env 
> variable). Activision Perl, being independent of cygwin, does not care 
> about that setting.
> 
> So, to be accurate, you'd have to check what *cygwin* expects, and 
> depending on that execute binmode(STDOUT) or not.
> 

Makes sense, I guess... except if you're running Cygwin, wouldn't 
Cygwin's Perl make a lot more sense?

	-hpa

```

## Johannes Schindelin, 2005-11-28 16:56

Subject: Re: use binmode(STDOUT) in git-status
Message-ID: <Pine.LNX.4.63.0511281756001.11697@wbgn013.biozentrum.uni-wuerzburg.de>
URL: https://gitlist.dev/e/Pine.LNX.4.63.0511281756001.11697%40wbgn013.biozentrum.uni-wuerzburg.de
In-Reply-To: <438B2B90.9010500@zytor.com>

```
Hi,

On Mon, 28 Nov 2005, H. Peter Anvin wrote:

> if you're running Cygwin, wouldn't Cygwin's Perl make a lot more sense?

I thought so, too, but I guess there's a reason that Activision's perl was 
used.

Hth,
Dscho

```

## Junio C Hamano, 2005-11-28 18:31

Subject: Re: use binmode(STDOUT) in git-status
Message-ID: <7vd5kkvd3q.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7vd5kkvd3q.fsf%40assigned-by-dhcp.cox.net
In-Reply-To: <81b0412b0511272334w393434e7lad3e3b102e6c3e9e@mail.gmail.com>

```
Alex Riesen <raa.lkml@gmail.com> writes:

> Activision's Perl generates CRLF unless STDOUT is binmoded, which is
> inconsistent with other output of git-status.

I do not think this is a kind of patch that I should accept to
apply to the generic part of the codepath, even if on sane
platforms binmode() could be a no-op.

You should not have to say binmode() when you are emitting plain
text (otherwise you have to say that everywhere which is
madness).  I presume the Cygwin version uses Perl from Cygwin
and would not have this problem?

If that is the case, maybe this patch should be maintained out
of tree by the maintainer of Windows port of git that does _not_
use Cygwin but ActiveState.

```

## Tim O'Callaghan, 2005-11-29 10:05

Subject: Re: use binmode(STDOUT) in git-status
Message-ID: <20051129100550.GA2124@ELSAMSW37164>
URL: https://gitlist.dev/e/20051129100550.GA2124%40ELSAMSW37164
In-Reply-To: <7vd5kkvd3q.fsf@assigned-by-dhcp.cox.net>

```
On Mon, Nov 28, 2005 at 10:31:05AM -0800, Junio C Hamano wrote:
> Alex Riesen <raa.lkml@gmail.com> writes:
> 
> > Activision's Perl generates CRLF unless STDOUT is binmoded, which is
> > inconsistent with other output of git-status.
> 
> I do not think this is a kind of patch that I should accept to
> apply to the generic part of the codepath, even if on sane
> platforms binmode() could be a no-op.
> 
> You should not have to say binmode() when you are emitting plain
> text (otherwise you have to say that everywhere which is
> madness).  I presume the Cygwin version uses Perl from Cygwin
> and would not have this problem?
> 
> If that is the case, maybe this patch should be maintained out
> of tree by the maintainer of Windows port of git that does _not_
> use Cygwin but ActiveState.
>

You could also check `perl -v` for the phrase "built for cygwin". I am not
sure how much of an issue this is though, because native windows support is
going to be a bit tricky without Cygwin as you also need (ba)sh, sed, grep,
etc.

Tim.

```

## Johannes Schindelin, 2005-11-29 11:44

Subject: Re: use binmode(STDOUT) in git-status
Message-ID: <Pine.LNX.4.63.0511291243090.2028@wbgn013.biozentrum.uni-wuerzburg.de>
URL: https://gitlist.dev/e/Pine.LNX.4.63.0511291243090.2028%40wbgn013.biozentrum.uni-wuerzburg.de
In-Reply-To: <20051129100550.GA2124@ELSAMSW37164>

```
Hi,

On Tue, 29 Nov 2005, Tim O'Callaghan wrote:

> [...] native windows support is going to be a bit tricky without Cygwin 
> as you also need (ba)sh, sed, grep, etc.

... most notably, not to forget fork().

Hth,
Dscho

```

## Alex Riesen, 2005-11-29 22:12

Subject: Re: use binmode(STDOUT) in git-status
Message-ID: <20051129221221.GC3033@steel.home>
URL: https://gitlist.dev/e/20051129221221.GC3033%40steel.home
In-Reply-To: <Pine.LNX.4.63.0511281756001.11697@wbgn013.biozentrum.uni-wuerzburg.de>

```
Johannes Schindelin, Mon, Nov 28, 2005 17:56:58 +0100:
> > if you're running Cygwin, wouldn't Cygwin's Perl make a lot more sense?
> 
> I thought so, too, but I guess there's a reason that Activision's perl was 
> used.

the reason were incompatible scripts (notably, the ones expecting crlf).

```

## Junio C Hamano, 2005-11-29 22:44

Subject: [OT] Activision (Re: use binmode(STDOUT) in git-status)
Message-ID: <7vwtir846o.fsf_-_@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7vwtir846o.fsf_-_%40assigned-by-dhcp.cox.net
In-Reply-To: <20051129221221.GC3033@steel.home>

```
Alex Riesen <raa.lkml@gmail.com> writes:

> Johannes Schindelin, Mon, Nov 28, 2005 17:56:58 +0100:
>> > if you're running Cygwin, wouldn't Cygwin's Perl make a lot more sense?
>> 
>> I thought so, too, but I guess there's a reason that Activision's perl was 
>> used.
>
> the reason were incompatible scripts (notably, the ones expecting crlf).

I wonder why people keep saying Activision ;-).  Taken with my
use of frotz and nitfol in the examples [*1*], somebody might
confuse us with a group of old Infocom [*2*] fans.

[1] http://en.wikipedia.org/wiki/Nitfol
[2] http://web.mit.edu/6.933/www/Fall2000/infocom/

```

## Johannes Schindelin, 2005-11-29 23:56

Subject: Re: [OT] Activision (Re: use binmode(STDOUT) in git-status)
Message-ID: <Pine.LNX.4.63.0511300055360.22317@wbgn013.biozentrum.uni-wuerzburg.de>
URL: https://gitlist.dev/e/Pine.LNX.4.63.0511300055360.22317%40wbgn013.biozentrum.uni-wuerzburg.de
In-Reply-To: <7vwtir846o.fsf_-_@assigned-by-dhcp.cox.net>

```
Hi,

On Tue, 29 Nov 2005, Junio C Hamano wrote:

> Alex Riesen <raa.lkml@gmail.com> writes:
> 
> > Johannes Schindelin, Mon, Nov 28, 2005 17:56:58 +0100:
> >> > if you're running Cygwin, wouldn't Cygwin's Perl make a lot more sense?
> >> 
> >> I thought so, too, but I guess there's a reason that Activision's perl was 
> >> used.
> >
> > the reason were incompatible scripts (notably, the ones expecting crlf).
> 
> I wonder why people keep saying Activision ;-).  Taken with my
> use of frotz and nitfol in the examples [*1*], somebody might
> confuse us with a group of old Infocom [*2*] fans.

Hey, you 0wn3d me there.

```
