Add error info when getting terminal dimensions.

This commit is contained in:
Csonka Mihaly 2020-03-21 02:49:36 +01:00
parent 77d0de839e
commit d371300fac

View file

@ -11,7 +11,7 @@ fn width_with_shell_out() -> u16 {
.arg("size")
.stderr(Stdio::inherit())
.output()
.unwrap()
.expect("Failed to execute stty")
} else {
Command::new("stty")
.arg("size")
@ -19,15 +19,16 @@ fn width_with_shell_out() -> u16 {
.arg("/dev/stderr")
.stderr(Stdio::inherit())
.output()
.unwrap()
.expect("Failed to execute stty")
};
match output.status.code() {
Some(0) => {
let stdout = String::from_utf8(output.stdout).unwrap();
let stdout = String::from_utf8(output.stdout).expect("Invalid utf8 output from stty");
let mut data = stdout.split_whitespace();
data.next();
u16::from_str_radix(data.next().unwrap(), 10).unwrap()
u16::from_str_radix(data.next().expect("Not enough data"), 10)
.expect("Invalid base-10 number")
}
_ => 40,
}