Terminal is not fully functional warning (again)

2,488 views
Skip to first unread message

Tale

unread,
Apr 10, 2012, 9:08:35 AM4/10/12
to msysGit
Hi,

I have just installed msysGit v1.7.10, and now when I type "git diff"
I get this warning:

WARNING: terminal is not fully functional
- (press RETURN)

I get this warning only if I run Git from the Windows command prompt,
in bash everything seems fine.

I have searched the archives for a solution, and apparently this can
happen with TERM=dumb. However, I don't have TERM defined at all.
Also, msysGit v1.7.9 worked just fine.

So I have had a quick look around, and it appears that the updated
less doesn't like TERM=winansi. So I propose this simple patch, which
changes it to TERM=msys (or would TERM=cygwin be better?).

-- >8 --
Subject: [PATCH] MinGW: default to TERM=msys

Supress warning "terminal is not fully functional" from less.

Signed-off-by: Theo Niessink <nies...@martinic.com>
---
compat/mingw.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/compat/mingw.c b/compat/mingw.c
index e6f331a..f019b1a 100644
--- a/compat/mingw.c
+++ b/compat/mingw.c
@@ -2125,7 +2125,7 @@ void mingw_startup()

/* simulate TERM to enable auto-color (see color.c) */
if (!getenv("TERM"))
- setenv("TERM", "winansi", 1);
+ setenv("TERM", "msys", 1);

/* initialize critical section for waitpid pinfo_t list */
InitializeCriticalSection(&pinfo_cs);
--
1.7.10.msysgit.1.dirty

Pat Thoyts

unread,
Apr 10, 2012, 1:03:18 PM4/10/12
to Tale, msysGit
> --

I can confirm this fault. As git bash shells seem to operate fine,
perhaps this is better just done in the git.cmd and git-cmd.cmd launch
scripts. For git-bash we seem to have TERM set to cygwin although as
setting TERM=msys works that would seem to make more sense. For
colours, we just require TERM to not be 'dumb'. I guess anything else
is down to 'less'.

Tale

unread,
Apr 11, 2012, 4:04:55 AM4/11/12
to msysGit
On 10 apr, 19:03, Pat Thoyts <pattho...@gmail.com> wrote:
> I can confirm this fault. As git bash shells seem to operate fine,
> perhaps this is better just done in the git.cmd and git-cmd.cmd launch
> scripts. For git-bash we seem to have TERM set to cygwin although as
> setting TERM=msys works that would seem to make more sense. For
> colours, we just require TERM to not be 'dumb'. I guess anything else
> is down to 'less'.- Tekst uit oorspronkelijk bericht niet weergeven -

Agreed! This patch instead then?

-- >8 --
Subject: [PATCH] Default to TERM=msys

Supress warning "terminal is not fully functional" from less.

Signed-off-by: Theo Niessink <nies...@martinic.com>
---
cmd/git.cmd | 1 +
git-cmd.bat | 1 +
2 files changed, 2 insertions(+)

diff --git a/cmd/git.cmd b/cmd/git.cmd
index dcd92b4..e697a23 100644
--- a/cmd/git.cmd
+++ b/cmd/git.cmd
@@ -10,6 +10,7 @@
@if not exist "%HOME%" @set HOME=%USERPROFILE%

@set PLINK_PROTOCOL=ssh
+@if not defined TERM set TERM=msys

@if "%1"=="gui" @goto gui

diff --git a/git-cmd.bat b/git-cmd.bat
index 6bfccff..a303800 100644
--- a/git-cmd.bat
+++ b/git-cmd.bat
@@ -10,6 +10,7 @@
@if not exist "%HOME%" @set HOME=%USERPROFILE%

@set PLINK_PROTOCOL=ssh
+@if not defined TERM set TERM=msys

@cd %HOME%
@start %COMSPEC%
--
1.7.10.msysgit.1

Johannes Schindelin

unread,
Apr 11, 2012, 11:37:51 AM4/11/12
to Tale, patt...@gmail.com, msysGit
Hi,

I am re-Cc:ing Pat (dunno whether there are others I am missing); this is
a little tedious, please respect the "Please reply-to-all" in the mail
signature in the future.

On Wed, 11 Apr 2012, Tale wrote:

> On 10 apr, 19:03, Pat Thoyts <pattho...@gmail.com> wrote:
> > I can confirm this fault. As git bash shells seem to operate fine,
> > perhaps this is better just done in the git.cmd and git-cmd.cmd launch
> > scripts. For git-bash we seem to have TERM set to cygwin although as
> > setting TERM=msys works that would seem to make more sense. For
> > colours, we just require TERM to not be 'dumb'. I guess anything else
> > is down to 'less'.- Tekst uit oorspronkelijk bericht niet weergeven -
>
> Agreed! This patch instead then?

I like it! Pat, if you agree, can you please apply and push?

Thanks!
Dscho

Pat Thoyts

unread,
Apr 11, 2012, 2:40:34 PM4/11/12
to Johannes Schindelin, Tale, msysGit
On 11 April 2012 16:37, Johannes Schindelin <Johannes....@gmx.de> wrote:
> Hi,

>> Agreed! This patch instead then?
>
> I like it! Pat, if you agree, can you please apply and push?

Done. I found in testing that we don't need to do anything to
git-cmd.cmd as that just opens a shell that lets you call git.cmd.
Redone the commit message too

karste...@dcon.de

unread,
Apr 11, 2012, 4:52:57 PM4/11/12
to Pat Thoyts, Johannes Schindelin, msysGit, Tale
msy...@googlegroups.com wrote on 11.04.2012 20:40:34:

> On 11 April 2012 16:37, Johannes Schindelin <Johannes.

> Schin...@gmx.de> wrote:
> > Hi,
> >> Agreed! This patch instead then?
> >
> > I like it! Pat, if you agree, can you please apply and push?
>
> Done. I found in testing that we don't need to do anything to
> git-cmd.cmd as that just opens a shell that lets you call git.cmd.
> Redone the commit message too
>

I realize I'm a bit late to the discussion, anyways...

If we set TERM in git.cmd (assuming that git.exe is always called via
git.cmd), we probably should also remove the special TERM handling in
mingw.c::mingw_startup(). There's no point in having similar workarounds
in two places.

However, I think it would be better to tackle the root of the problem.
Git's auto-color mode is enabled under these circumstances (see
color.c::check_auto_color):
1) the user has explicitly set color.ui = auto (actually: != always|never)
2) stdout is a tty
3) TERM is set
4) TERM is not "dumb"

In the presence of (1) and (4), I think that (3) can safely be removed for
systems that usually don't have a TERM variable (probably Mac OS X, too?).
Git isn't interested in a proper TERM setting at all, so why require it?
Something like this:

------8<-------
diff --git a/color.c b/color.c
index e8e2681..c92d7cc 100644
--- a/color.c
+++ b/color.c
@@ -186,7 +186,7 @@ static int check_auto_color(void)
color_stdout_is_tty = isatty(1);
if (color_stdout_is_tty || (pager_in_use() && pager_use_color)) {
char *term = getenv("TERM");
- if (term && strcmp(term, "dumb"))
+ if (!term || strcmp(term, "dumb"))
return 1;
}
return 0;
diff --git a/compat/mingw.c b/compat/mingw.c
index e6f331a..4a58866 100644
--- a/compat/mingw.c
+++ b/compat/mingw.c
@@ -2123,10 +2123,6 @@ void mingw_startup()
setenv("TMPDIR", tmp, 1);
}

- /* simulate TERM to enable auto-color (see color.c) */
- if (!getenv("TERM"))


- setenv("TERM", "winansi", 1);

-


/* initialize critical section for waitpid pinfo_t list */
InitializeCriticalSection(&pinfo_cs);

-----8<-----

Actually, there are two more places that check TERM in pretty much the
same way, so to make it pretty I'd add a is_terminal_dumb function that
could even do different things on *nix/Mac/Windows.

Btw.: Less works without a TERM setting because MSYS.dll sets TERM=cygwin
in it's startup code, and it doesn't work with TERM=winansi because
there's no such entry in etc/termcap.

Bye,
Karsten

Reply all
Reply to author
Forward
0 new messages