From 8484de86c7c024c7af521ab9a4973740fa903cef Mon Sep 17 00:00:00 2001 From: Alvydas Vitkauskas Date: Mon, 29 Jul 2019 01:23:41 +0300 Subject: [PATCH] fix #1353 os.get_line --- vlib/os/os.v | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/vlib/os/os.v b/vlib/os/os.v index 1211a08163..c149bfb529 100644 --- a/vlib/os/os.v +++ b/vlib/os/os.v @@ -509,11 +509,12 @@ pub fn filename(path string) string { // get_line returns a one-line string from stdin pub fn get_line() string { str := get_raw_line() - if str[str.len - 1] == `\n` { - return str.substr(0, str.len - 1) - } - - return str + $if windows { + return str.trim_right('\r\n') + } + $else { + return str.trim_right('\n') + } } // get_raw_line returns a one-line string from stdin along with '\n' if there is any