t9term: set TERM=dumb instead of TERM=9term - plan9port - [fork] Plan 9 from user space
 (HTM) git clone git://src.adamsgaard.dk/plan9port
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit bf63f986ff1a433ab6cce5287d51c191036f0a65
 (DIR) parent 2bc9a13faf0abcfa43cddc8c226b2f742b764c4a
 (HTM) Author: Russ Cox <rsc@swtch.com>
       Date:   Tue,  6 Aug 2013 09:42:10 -0400
       
       9term: set TERM=dumb instead of TERM=9term
       
       Everyone seems to assume that TERM != dumb implies
       ANSI escape codes are okay. In fact, many people assume
       tthat unconditionally, but it is easier to argue back about
       TERM=dumb than TERM=9term.
       
       This applies to acme win too, because they share the code.
       
       Set termprog=9term or termprog=win for clients who
       need to know.
       
       R=rsc
       CC=r
       https://codereview.appspot.com/12532043
       
       Diffstat:
         M src/cmd/9term/9term.c               |       1 +
         M src/cmd/9term/rcstart.c             |      11 ++++++++++-
         M src/cmd/9term/term.h                |       1 +
         M src/cmd/9term/win.c                 |       1 +
       
       4 files changed, 13 insertions(+), 1 deletion(-)
       ---
 (DIR) diff --git a/src/cmd/9term/9term.c b/src/cmd/9term/9term.c
       t@@ -15,6 +15,7 @@
        #include "fns.h"
        #include "term.h"
        
       +const char *termprog = "9term";
        int use9wm;
        int mainpid;
        int mousepid;
 (DIR) diff --git a/src/cmd/9term/rcstart.c b/src/cmd/9term/rcstart.c
       t@@ -77,7 +77,16 @@ rcstart(int argc, char **argv, int *pfd, int *tfd)
                 */
                notifyoff("sys: window size change");
        
       -        putenv("TERM", "9term");
       +        // This used to be TERM=9term but we don't know of anything that cares.
       +        // Worse, various cc have started assuming that TERM != dumb implies
       +        // the ability to understand ANSI escape codes. 9term will squelch them
       +        // but acme win does not.
       +        putenv("TERM", "dumb");
       +
       +        // Set $termprog to 9term or win for those who care about what kind of
       +        // dumb terminal this is.
       +        putenv("termprog", (char*)termprog);
       +
                pid = fork();
                switch(pid){
                case 0:
 (DIR) diff --git a/src/cmd/9term/term.h b/src/cmd/9term/term.h
       t@@ -10,3 +10,4 @@ extern int loginshell;
        extern void echoed(char*, int);
        extern int echocancel(char*, int);
        extern int dropcrnl(char*, int);
       +extern const char *termprog;
 (DIR) diff --git a/src/cmd/9term/win.c b/src/cmd/9term/win.c
       t@@ -5,6 +5,7 @@
        #include <9pclient.h>
        #include "term.h"
        
       +const char *termprog = "win";
        
        #define        EVENTSIZE        256
        #define        STACK        32768