Skip to content

Commit 05f23f9

Browse files
committed
doctor: Split version str with .lines() to account for Windows' \r\n
On Windows at least `adb` prints it version string with carriage return; leaving the `\r` in there (by only splitting on `\n`) and not trimming the string causes us to print its version with a `\r` at the end, clearing the whole line (i.e. it would print `adb 1.0.41\r` followed by the path, and then only the path remains on this line). Rust's `.lines()` implementation already takes care of this by splitting (inclusively) on `\n` and trimming off that `\n` and _optionally also a `\r`_ in the iterator before returning it to us.
1 parent 203d111 commit 05f23f9

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

xbuild/src/command/doctor.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ impl Check {
146146
.output()?;
147147
anyhow::ensure!(output.status.success(), "failed to run {}", self.name);
148148
let output = std::str::from_utf8(&output.stdout)?;
149-
if let Some(line) = output.split('\n').nth(version.row as _) {
149+
if let Some(line) = output.lines().nth(version.row as _) {
150150
let mut col = version.col as usize;
151151
if line.starts_with("Apple ") || line.starts_with("Homebrew ") {
152152
col += 1;

0 commit comments

Comments
 (0)