Skip to content

Commit

Permalink
fix a unicode issue
Browse files Browse the repository at this point in the history
  • Loading branch information
mitnk committed Sep 26, 2024
1 parent 5c3ef96 commit 2e78b7d
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# cicada Release Notes

## 0.9.40 - 2024.09.26

- Fix a Unicode issue for commands end with `&`.

## 0.9.39 - 2024.09.22

- upgraded deps to support latest Rust.
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
edition = "2021"
build = "src/build.rs"
name = "cicada"
version = "0.9.39"
version = "0.9.40"
authors = ["Hugo Wang <w@mitnk.com>"]

description = "A simple Bash-like Unix shell."
Expand Down
9 changes: 8 additions & 1 deletion src/parsers/parser_line.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ pub fn line_to_cmds(line: &str) -> Vec<String> {
let mut sep = String::new();
let mut token = String::new();
let mut has_backslash = false;
let len = line.len();
let len = line.chars().count();
for (i, c) in line.chars().enumerate() {
if has_backslash {
token.push('\\');
Expand Down Expand Up @@ -951,5 +951,12 @@ mod tests {
];
let line_exp = "echo \"a\\\"b\"";
assert_eq!(tokens_to_line(&tokens), line_exp);

let tokens = vec![
("".to_string(), "echo".to_string()),
("\"".to_string(), "中文".to_string()),
];
let line_exp = "echo \"中文\"";
assert_eq!(tokens_to_line(&tokens), line_exp);
}
}

0 comments on commit 2e78b7d

Please sign in to comment.