Fix isCygwinPipeName to accept Windows 7 trailing suffix (#90)
diff --git a/isatty_windows.go b/isatty_windows.go index 41edab0..5f29c11 100644 --- a/isatty_windows.go +++ b/isatty_windows.go
@@ -47,9 +47,10 @@ // Check pipe name is used for cygwin/msys2 pty. // Cygwin/MSYS2 PTY has a name like: // \{cygwin,msys}-XXXXXXXXXXXXXXXX-ptyN-{from,to}-master +// On Windows 7 a trailing suffix (e.g. "-nat") may be appended. func isCygwinPipeName(name string) bool { token := strings.Split(name, "-") - if len(token) != 5 { + if len(token) < 5 { return false } @@ -76,6 +77,12 @@ return false } + for _, t := range token[5:] { + if t == "" { + return false + } + } + return true }
diff --git a/isatty_windows_test.go b/isatty_windows_test.go index ec525b0..0eab70c 100644 --- a/isatty_windows_test.go +++ b/isatty_windows_test.go
@@ -27,6 +27,8 @@ {`\Device\NamedPipe\cygwin-e022582115c10879-pty4-from-master`, true}, {`\Device\NamedPipe\msys-e022582115c10879-pty4-to-master`, true}, {`Device\NamedPipe\cygwin-e022582115c10879-pty4-to-master`, false}, + {`\cygwin-e022582115c10879-pty0-from-master-nat`, true}, + {`\msys-1888ae32e00d56aa-pty0-from-master-nat`, true}, } for _, test := range tests {