From ab79440347f3a77f9d44faa1dac1e6fe16ff5eb0 Mon Sep 17 00:00:00 2001 From: Linus789 Date: Tue, 21 Feb 2023 23:45:03 +0100 Subject: [PATCH] fix parsing adb property fallback trim the trailing newline... --- adb/device.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/adb/device.go b/adb/device.go index 791a562..bc8ee6b 100644 --- a/adb/device.go +++ b/adb/device.go @@ -120,7 +120,14 @@ func (d *Device) AdbProp(property string) (string, error) { return "", err } result := string(stdout) - if result == "" || result == "\n" || result == "\r\n" || result == "\r" { + if strings.HasSuffix(result, "\r\n") { + result = strings.TrimSuffix(result, "\r\n") + } else if strings.HasSuffix(result, "\n") { + result = strings.TrimSuffix(result, "\n") + } else if strings.HasSuffix(result, "\r") { + result = strings.TrimSuffix(result, "\r") + } + if result == "" { return "", fmt.Errorf("could not get property %s", property) } return result, nil