Do not proceed if $TERM is invalid

Related #305
pull/326/head
Junegunn Choi 9 years ago
parent dce6fe6f2d
commit 02bd2d2adf

@ -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)

@ -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

Loading…
Cancel
Save