Exit 2 instead of panic when failed to open /dev/tty

This commit is contained in:
Junegunn Choi 2017-08-02 02:50:12 +09:00
parent a56489bc7f
commit 39dbc8acdb
No known key found for this signature in database
GPG Key ID: 254BC280FEF9C627

View File

@ -32,7 +32,8 @@ var offsetRegexp *regexp.Regexp = regexp.MustCompile("\x1b\\[([0-9]+);([0-9]+)R"
func openTtyIn() *os.File {
in, err := os.OpenFile(consoleDevice, syscall.O_RDONLY, 0)
if err != nil {
panic("Failed to open " + consoleDevice)
fmt.Fprintln(os.Stderr, "Failed to open "+consoleDevice)
os.Exit(2)
}
return in
}