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 <ian.campbell@docker.com>
| ... | ... |
@@ -131,7 +131,7 @@ github.com/spf13/cobra v1.5.1 https://github.com/dnephin/cobra.git |
| 131 | 131 |
github.com/spf13/pflag 9ff6c6923cfffbcd502984b8e0c80539a94968b7 |
| 132 | 132 |
github.com/inconshreveable/mousetrap 76626ae9c91c4f2a10f34cad8ce83ea42c93bb75 |
| 133 | 133 |
github.com/flynn-archive/go-shlex 3f9db97f856818214da2e1057f8ad84803971cff |
| 134 |
-github.com/Nvveen/Gotty 6018b68f96b839edfbe3fb48668853f5dbad88a3 https://github.com/ijc25/Gotty |
|
| 134 |
+github.com/Nvveen/Gotty a8b993ba6abdb0e0c12b0125c603323a71c7790c https://github.com/ijc25/Gotty |
|
| 135 | 135 |
|
| 136 | 136 |
# metrics |
| 137 | 137 |
github.com/docker/go-metrics 86138d05f285fd9737a99bee2d9be30866b59d72 |
| ... | ... |
@@ -13,6 +13,7 @@ import ( |
| 13 | 13 |
"errors" |
| 14 | 14 |
"fmt" |
| 15 | 15 |
"os" |
| 16 |
+ "path" |
|
| 16 | 17 |
"reflect" |
| 17 | 18 |
"strings" |
| 18 | 19 |
"sync" |
| ... | ... |
@@ -22,33 +23,30 @@ import ( |
| 22 | 22 |
// If something went wrong reading the terminfo database file, an error is |
| 23 | 23 |
// returned. |
| 24 | 24 |
func OpenTermInfo(termName string) (*TermInfo, error) {
|
| 25 |
- var term *TermInfo |
|
| 26 |
- var err error |
|
| 25 |
+ if len(termName) == 0 {
|
|
| 26 |
+ return nil, errors.New("No termname given")
|
|
| 27 |
+ } |
|
| 27 | 28 |
// Find the environment variables |
| 28 |
- termloc := os.Getenv("TERMINFO")
|
|
| 29 |
- if len(termloc) == 0 {
|
|
| 29 |
+ if termloc := os.Getenv("TERMINFO"); len(termloc) > 0 {
|
|
| 30 |
+ return readTermInfo(path.Join(termloc, string(termName[0]), termName)) |
|
| 31 |
+ } else {
|
|
| 30 | 32 |
// Search like ncurses |
| 31 |
- locations := []string{os.Getenv("HOME") + "/.terminfo/", "/etc/terminfo/",
|
|
| 32 |
- "/lib/terminfo/", "/usr/share/terminfo/"} |
|
| 33 |
- var path string |
|
| 33 |
+ locations := []string{}
|
|
| 34 |
+ if h := os.Getenv("HOME"); len(h) > 0 {
|
|
| 35 |
+ locations = append(locations, path.Join(h, ".terminfo")) |
|
| 36 |
+ } |
|
| 37 |
+ locations = append(locations, |
|
| 38 |
+ "/etc/terminfo/", |
|
| 39 |
+ "/lib/terminfo/", |
|
| 40 |
+ "/usr/share/terminfo/") |
|
| 34 | 41 |
for _, str := range locations {
|
| 35 |
- // Construct path |
|
| 36 |
- path = str + string(termName[0]) + "/" + termName |
|
| 37 |
- // Check if path can be opened |
|
| 38 |
- file, _ := os.Open(path) |
|
| 39 |
- if file != nil {
|
|
| 40 |
- // Path can open, fall out and use current path |
|
| 41 |
- file.Close() |
|
| 42 |
- break |
|
| 42 |
+ term, err := readTermInfo(path.Join(str, string(termName[0]), termName)) |
|
| 43 |
+ if err == nil {
|
|
| 44 |
+ return term, nil |
|
| 43 | 45 |
} |
| 44 | 46 |
} |
| 45 |
- if len(path) > 0 {
|
|
| 46 |
- term, err = readTermInfo(path) |
|
| 47 |
- } else {
|
|
| 48 |
- err = errors.New(fmt.Sprintf("No terminfo file(-location) found"))
|
|
| 49 |
- } |
|
| 47 |
+ return nil, errors.New("No terminfo file(-location) found")
|
|
| 50 | 48 |
} |
| 51 |
- return term, err |
|
| 52 | 49 |
} |
| 53 | 50 |
|
| 54 | 51 |
// Open a terminfo file from the environment variable containing the current |