From 94b90b86d89e19f59054a3b7f381bb8a940c411f Mon Sep 17 00:00:00 2001 From: zhuweihao Date: Wed, 10 Apr 2024 08:07:26 +0000 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9issues#38=20bug:=20histor?= =?UTF-8?q?y=5Fcommand=E6=B2=A1=E8=AE=B0=E5=BD=95=E5=88=B0txt=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/shell/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/shell/mod.rs b/src/shell/mod.rs index b41f5af..6be67d3 100644 --- a/src/shell/mod.rs +++ b/src/shell/mod.rs @@ -101,12 +101,12 @@ impl Shell { { self.history_commands .push(Rc::new(RefCell::new(command_bytes.clone()))); + self.write_commands(); }; if !command_bytes.iter().all(|&byte| byte == b' ') { self.exec_commands_in_line(&command_bytes); } } - self.write_commands(); } fn exec_commands_in_line(&mut self, command_bytes: &Vec) { @@ -136,7 +136,7 @@ impl Shell { fn write_commands(&self) { let mut file = OpenOptions::new() - .append(false) + .write(true).truncate(true) .open("history_commands.txt") .unwrap(); for command_line in &self.history_commands { From 6e76e272bf37c786ee20622ed1bb9be27cf7d415 Mon Sep 17 00:00:00 2001 From: zhuweihao Date: Wed, 10 Apr 2024 09:58:24 +0000 Subject: [PATCH 2/2] =?UTF-8?q?cargo=20fmt=E8=A7=84=E8=8C=83=E6=A0=BC?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/shell/mod.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/shell/mod.rs b/src/shell/mod.rs index 6be67d3..b0ebe60 100644 --- a/src/shell/mod.rs +++ b/src/shell/mod.rs @@ -136,7 +136,8 @@ impl Shell { fn write_commands(&self) { let mut file = OpenOptions::new() - .write(true).truncate(true) + .write(true) + .truncate(true) .open("history_commands.txt") .unwrap(); for command_line in &self.history_commands {