Re: [PATCH 1/2] git-svn, perl/Git.pm: add central method for prompting passwords honoring GIT_ASKPASS and SSH_ASKPASS
- From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
- Date
- Jan 3, 2012, 12:06 UTC
- Message-ID
- <CACBZZX4HdrfPZzEL4=YV0_Tt6inYpZjSRy-HnUdGJ6YFOrE0Ag@mail.gmail.com>
- In-Reply-To
- <CACBZZX6iMobuU90skpbNPaGQFxYNOAjmZ6ceO4PGqfZSMkgePQ@mail.gmail.com>
On Tue, Jan 3, 2012 at 13:03, Ævar Arnfjörð Bjarmason <avarab@gmail.com> wrote:
Show 39 quoted lines
> On Tue, Jan 3, 2012 at 11:25, Sven Strickroth > <sven.strickroth@tu-clausthal.de> wrote: >> Am 03.01.2012 11:17 schrieb Ævar Arnfjörð Bjarmason: >>>> + $ret = <$fh>; >>>> + $ret =~ s/[\012\015]//g; # strip \n\r, chomp does not work on all systems (i.e. windows) as expected >>> >>> Urm yes it does. \n in Perl is magical and doesn't mean \012 like it >>> does in some languages. It means "The Platform's Native >>> Newline". >>> >>> Which is \012 on Unix, \015\012 on Windows, and was \015 on Mac OS >>> until support for it was removed. This is covered in the second >>> section of "perldoc perlport". >>> >>> Can you show me a case where it fails, and under what environment >>> exactly? Maybe it's e.g.s some Cygwin-specific peculiarity, in which >>> case we could check for that platform specifically. >> >> I'm using msys perl (shipped with msysgit) and there just using chomp() >> did not work. > > That's odd, what does this print: > > perl -MData::Dumper -MFile::Temp=tempfile -we 'my $str = > "moo\015\012"; my ($fh, $name) = tempfile(); print $fh $str; close > $fh; open my $in, "<", $name or die $!; my $in_str = <$in>; chomp(my > $cin_str = $in_str); print "in_str:<$in_str> cin_str:<$cin_str> > END\n"' > > And how about this: > > perl -MData::Dumper -MFile::Temp=tempfile -we 'my $str = > "moo\015\012"; my ($fh, $name) = tempfile(); print $fh $str; close > $fh; open my $in, "<:crlf", $name or die $!; my $in_str = <$in>; > chomp(my $cin_str = $in_str); print "in_str:<$in_str> > cin_str:<$cin_str> END\n"' > > It could be that there's some bug in either perl or mingw's build of > perl where it won't turn on the :crlf IO layer by default.
Or actually you could do this before running your patch, except you have to change the code to use chomp() instead of your regex hack:
export PERLIO=crlf
If that makes it work we should just do that somewhere else (e.g. at the top of Git.pm) if we detect Windows, which'll make chomp() work as intended everywhere.