git-svn: delay term initialization

On my Debian 7 system, this fixes annoying warnings when the output
of "git svn" commands are redirected:

    Unable to get Terminal Size. The TIOCGWINSZ ioctl didn't work.
    The COLUMNS and LINES environment variables didn't work. The
    resize program didn't work.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
This commit is contained in:
Eric Wong 2014-09-14 07:38:29 +00:00
parent a831a3fd86
commit 30d45f798d

View File

@ -306,13 +306,16 @@ sub readline {
} }
package main; package main;
my $term = eval { my $term;
$ENV{"GIT_SVN_NOTTY"} sub term_init {
? new Term::ReadLine 'git-svn', \*STDIN, \*STDOUT $term = eval {
: new Term::ReadLine 'git-svn'; $ENV{"GIT_SVN_NOTTY"}
}; ? new Term::ReadLine 'git-svn', \*STDIN, \*STDOUT
if ($@) { : new Term::ReadLine 'git-svn';
$term = new FakeTerm "$@: going non-interactive"; };
if ($@) {
$term = new FakeTerm "$@: going non-interactive";
}
} }
my $cmd; my $cmd;
@ -424,6 +427,7 @@ sub ask {
my $default = $arg{default}; my $default = $arg{default};
my $resp; my $resp;
my $i = 0; my $i = 0;
term_init() unless $term;
if ( !( defined($term->IN) if ( !( defined($term->IN)
&& defined( fileno($term->IN) ) && defined( fileno($term->IN) )