Skip to content

Commit c95caa1

Browse files
committed
Fix multiline input on Windows
1 parent 22a9610 commit c95caa1

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

src/main.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -126,14 +126,16 @@ fn read_until_empty_line(input: &mut String) -> Result<i32, std::io::Error> {
126126
io::stdout().flush().expect("Could not flush stdout");
127127
let mut line = String::new();
128128
match io::stdin().read_line(&mut line) {
129-
Ok(0) => {
130-
return Ok(0);
131-
}
132-
Ok(1) => {
133-
return Ok(1);
134-
}
135129
Ok(_) => {
136-
input.push_str(&line);
130+
line = line
131+
.trim_right_matches(|c| c == '\r' || c == '\n')
132+
.to_string();
133+
if line.len() == 0 {
134+
return Ok(0); // DOne
135+
} else {
136+
input.push_str(&line);
137+
input.push_str("\n");
138+
}
137139
}
138140
Err(msg) => {
139141
return Err(msg);
@@ -167,9 +169,6 @@ fn run_shell() {
167169
input = String::new();
168170
} else {
169171
match read_until_empty_line(&mut input) {
170-
Ok(0) => {
171-
break;
172-
}
173172
Ok(_) => {
174173
shell_exec(&mut vm, &input, vars.clone());
175174
}

0 commit comments

Comments
 (0)