Skip to content

Commit

Permalink
修复history_commands没记录到txt中 (#39)
Browse files Browse the repository at this point in the history
* 修改issues#38 bug: history_command没记录到txt中

* cargo fmt规范格式
  • Loading branch information
zhuweihao12138 authored Apr 10, 2024
1 parent 46fb311 commit a066b0a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/shell/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<u8>) {
Expand Down Expand Up @@ -136,7 +136,8 @@ 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 {
Expand Down

0 comments on commit a066b0a

Please sign in to comment.