From b7ced33036f24852e7d8095c7f38f5bb8d2b8ef9 Mon Sep 17 00:00:00 2001 From: Ian Campbell Date: Thu, 6 Apr 2017 11:13:25 +0100 Subject: [PATCH] Revendor github.com/Nvveen/Gotty for github.com/Nvveen/Gotty#2 This fixes https://github.com/docker/docker/issues/32400 We were already actually vendoring from github.com/ijc25/Gotty in order to pickup github.com/Nvveen/Gotty#1. github.com/ijc25/Gotty#master now contains merges of both of those upstream PRs. Signed-off-by: Ian Campbell --- vendor.conf | 2 +- vendor/github.com/Nvveen/Gotty/gotty.go | 40 ++++++++++++------------- 2 files changed, 20 insertions(+), 22 deletions(-) diff --git a/vendor.conf b/vendor.conf index 6a31556c2e..29db3350c1 100644 --- a/vendor.conf +++ b/vendor.conf @@ -131,7 +131,7 @@ github.com/spf13/cobra v1.5.1 https://github.com/dnephin/cobra.git github.com/spf13/pflag 9ff6c6923cfffbcd502984b8e0c80539a94968b7 github.com/inconshreveable/mousetrap 76626ae9c91c4f2a10f34cad8ce83ea42c93bb75 github.com/flynn-archive/go-shlex 3f9db97f856818214da2e1057f8ad84803971cff -github.com/Nvveen/Gotty 6018b68f96b839edfbe3fb48668853f5dbad88a3 https://github.com/ijc25/Gotty +github.com/Nvveen/Gotty a8b993ba6abdb0e0c12b0125c603323a71c7790c https://github.com/ijc25/Gotty # metrics github.com/docker/go-metrics 86138d05f285fd9737a99bee2d9be30866b59d72 diff --git a/vendor/github.com/Nvveen/Gotty/gotty.go b/vendor/github.com/Nvveen/Gotty/gotty.go index b8bb80ae93..c329778a1d 100644 --- a/vendor/github.com/Nvveen/Gotty/gotty.go +++ b/vendor/github.com/Nvveen/Gotty/gotty.go @@ -13,6 +13,7 @@ import ( "errors" "fmt" "os" + "path" "reflect" "strings" "sync" @@ -22,33 +23,30 @@ import ( // If something went wrong reading the terminfo database file, an error is // returned. func OpenTermInfo(termName string) (*TermInfo, error) { - var term *TermInfo - var err error + if len(termName) == 0 { + return nil, errors.New("No termname given") + } // Find the environment variables - termloc := os.Getenv("TERMINFO") - if len(termloc) == 0 { + if termloc := os.Getenv("TERMINFO"); len(termloc) > 0 { + return readTermInfo(path.Join(termloc, string(termName[0]), termName)) + } else { // Search like ncurses - locations := []string{os.Getenv("HOME") + "/.terminfo/", "/etc/terminfo/", - "/lib/terminfo/", "/usr/share/terminfo/"} - var path string + locations := []string{} + if h := os.Getenv("HOME"); len(h) > 0 { + locations = append(locations, path.Join(h, ".terminfo")) + } + locations = append(locations, + "/etc/terminfo/", + "/lib/terminfo/", + "/usr/share/terminfo/") for _, str := range locations { - // Construct path - path = str + string(termName[0]) + "/" + termName - // Check if path can be opened - file, _ := os.Open(path) - if file != nil { - // Path can open, fall out and use current path - file.Close() - break + term, err := readTermInfo(path.Join(str, string(termName[0]), termName)) + if err == nil { + return term, nil } } - if len(path) > 0 { - term, err = readTermInfo(path) - } else { - err = errors.New(fmt.Sprintf("No terminfo file(-location) found")) - } + return nil, errors.New("No terminfo file(-location) found") } - return term, err } // Open a terminfo file from the environment variable containing the current