diff options
author | Junegunn Choi <junegunn.c@gmail.com> | 2015-07-28 14:35:46 +0900 |
---|---|---|
committer | Junegunn Choi <junegunn.c@gmail.com> | 2015-07-28 14:35:46 +0900 |
commit | 02bd2d2adf73feddd57bdac6c5fbaee56edaf53e (patch) | |
tree | 6a745d29663b0d49bf791706169375065ab3d967 | |
parent | dce6fe6f2ddacf0cef675342d71b6c740fdbc6b2 (diff) |
Do not proceed if $TERM is invalid
Related #305
-rw-r--r-- | src/curses/curses.go | 5 | ||||
-rw-r--r-- | test/test_go.rb | 5 |
2 files changed, 10 insertions, 0 deletions
diff --git a/src/curses/curses.go b/src/curses/curses.go index 51b68132..3de8e982 100644 --- a/src/curses/curses.go +++ b/src/curses/curses.go @@ -8,6 +8,7 @@ package curses import "C" import ( + "fmt" "os" "os/signal" "syscall" @@ -258,6 +259,10 @@ func Init(theme *ColorTheme, black bool, mouse bool) { C.setlocale(C.LC_ALL, C.CString("")) _screen = C.newterm(nil, C.stderr, C.stdin) + if _screen == nil { + fmt.Println("Invalid $TERM: " + os.Getenv("TERM")) + os.Exit(1) + } C.set_term(_screen) if mouse { C.mousemask(C.ALL_MOUSE_EVENTS, nil) diff --git a/test/test_go.rb b/test/test_go.rb index f702efcb..75fc01ca 100644 --- a/test/test_go.rb +++ b/test/test_go.rb @@ -743,6 +743,11 @@ class TestGoFZF < TestBase tmux.send_keys :Enter end + def test_invalid_term + tmux.send_keys "TERM=xxx fzf", :Enter + tmux.until { |lines| lines.any? { |l| l.include? 'Invalid $TERM: xxx' } } + end + private def writelines path, lines File.unlink path while File.exists? path |