Date: Wed, 2 Jun 2010 19:16:58 +0000 (UTC) From: Jilles Tjoelker <jilles@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r208755 - head/bin/sh Message-ID: <201006021916.o52JGwkU044066@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: jilles Date: Wed Jun 2 19:16:58 2010 New Revision: 208755 URL: http://svn.freebsd.org/changeset/base/208755 Log: sh: Pass TERM changes to libedit. I have changed the patch slightly to ignore TERM changes in subshells. PR: bin/146916 Submitted by: Guy Yur Obtained from: NetBSD Modified: head/bin/sh/histedit.c head/bin/sh/myhistedit.h head/bin/sh/var.c head/bin/sh/var.h Modified: head/bin/sh/histedit.c ============================================================================== --- head/bin/sh/histedit.c Wed Jun 2 18:46:12 2010 (r208754) +++ head/bin/sh/histedit.c Wed Jun 2 19:16:58 2010 (r208755) @@ -98,6 +98,8 @@ histedit(void) /* * turn editing on */ + char *term; + INTOFF; if (el_in == NULL) el_in = fdopen(0, "r"); @@ -107,6 +109,11 @@ histedit(void) el_out = fdopen(2, "w"); if (el_in == NULL || el_err == NULL || el_out == NULL) goto bad; + term = lookupvar("TERM"); + if (term) + setenv("TERM", term, 1); + else + unsetenv("TERM"); el = el_init(arg0, el_in, el_out, el_err); if (el != NULL) { if (hist) @@ -160,6 +167,13 @@ sethistsize(hs) } } +void +setterm(const char *term) +{ + if (rootshell && el != NULL && term != NULL) + el_set(el, EL_TERMINAL, term); +} + int histcmd(int argc, char **argv) { Modified: head/bin/sh/myhistedit.h ============================================================================== --- head/bin/sh/myhistedit.h Wed Jun 2 18:46:12 2010 (r208754) +++ head/bin/sh/myhistedit.h Wed Jun 2 19:16:58 2010 (r208755) @@ -38,6 +38,7 @@ extern int displayhist; void histedit(void); void sethistsize(const char *); +void setterm(const char *); int histcmd(int, char **); int not_fcnumber(const char *); int str_to_event(const char *, int); Modified: head/bin/sh/var.c ============================================================================== --- head/bin/sh/var.c Wed Jun 2 18:46:12 2010 (r208754) +++ head/bin/sh/var.c Wed Jun 2 19:16:58 2010 (r208755) @@ -80,6 +80,7 @@ struct varinit { #ifndef NO_HISTORY struct var vhistsize; +struct var vterm; #endif struct var vifs; struct var vmail; @@ -114,6 +115,10 @@ STATIC const struct varinit varinit[] = NULL }, { &vps4, 0, "PS4=+ ", NULL }, +#ifndef NO_HISTORY + { &vterm, VUNSET, "TERM=", + setterm }, +#endif { &voptind, 0, "OPTIND=1", getoptsreset }, { NULL, 0, NULL, Modified: head/bin/sh/var.h ============================================================================== --- head/bin/sh/var.h Wed Jun 2 18:46:12 2010 (r208754) +++ head/bin/sh/var.h Wed Jun 2 19:16:58 2010 (r208755) @@ -77,6 +77,7 @@ extern struct var vps2; extern struct var vps4; #ifndef NO_HISTORY extern struct var vhistsize; +extern struct var vterm; #endif /* @@ -96,6 +97,7 @@ extern struct var vhistsize; #define optindval() (voptind.text + 7) #ifndef NO_HISTORY #define histsizeval() (vhistsize.text + 9) +#define termval() (vterm.text + 5) #endif #define mpathset() ((vmpath.flags & VUNSET) == 0)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201006021916.o52JGwkU044066>