threads / discuss / 2699

use binmode(STDOUT) in git-status

Subject: use binmode(STDOUT) in git-status

## tl;dr

11 messages between Nov 28, 2005 and Nov 29, 2005.

replies: 10people: 5as markdown or json

Alex Riesen· Nov 28, 2005, 07:34 UTC · lore

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· Nov 28, 2005, 15:55 UTC · re: Alex Riesen · lore

Re: use binmode(STDOUT) in git-status

Alex Riesen wrote:
Show 5 quoted lines
> 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· Nov 28, 2005, 16:02 UTC · re: H. Peter Anvin · lore

Re: use binmode(STDOUT) in git-status

Hi,
On Mon, 28 Nov 2005, H. Peter Anvin wrote:
Show 9 quoted lines
> 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· Nov 28, 2005, 16:08 UTC · re: Johannes Schindelin · lore

Re: use binmode(STDOUT) in git-status

Johannes Schindelin wrote:
Show 9 quoted lines
> 
> 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· Nov 28, 2005, 16:56 UTC · re: H. Peter Anvin · lore

Re: use binmode(STDOUT) in git-status

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

Alex Riesen· Nov 29, 2005, 22:12 UTC · re: Johannes Schindelin · lore

Re: use binmode(STDOUT) in git-status

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· Nov 29, 2005, 22:44 UTC · re: Alex Riesen · lore

[OT] Activision (Re: use binmode(STDOUT) in git-status)

Alex Riesen <raa.lkml@gmail.com> writes:
Show 7 quoted lines
> 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· Nov 29, 2005, 23:56 UTC · re: Junio C Hamano · lore

Re: [OT] Activision (Re: use binmode(STDOUT) in git-status)

Hi,
On Tue, 29 Nov 2005, Junio C Hamano wrote:
Show 13 quoted lines
> 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.
Junio C Hamano· Nov 28, 2005, 18:31 UTC · re: Alex Riesen · lore

Re: use binmode(STDOUT) in git-status

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· Nov 29, 2005, 10:05 UTC · re: Junio C Hamano · lore

Re: use binmode(STDOUT) in git-status

On Mon, Nov 28, 2005 at 10:31:05AM -0800, Junio C Hamano wrote:
Show 18 quoted lines
> 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· Nov 29, 2005, 11:44 UTC · re: Tim O'Callaghan · lore

Re: use binmode(STDOUT) in git-status

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

← back to recent threads