diff --git a/CHANGELOG.md b/CHANGELOG.md index f782f78..823c118 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. diff --git a/Cargo.lock b/Cargo.lock index 8782f78..70a6d64 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -102,7 +102,7 @@ checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" [[package]] name = "cicada" -version = "0.9.39" +version = "0.9.40" dependencies = [ "clap 3.2.25", "errno 0.3.9", diff --git a/Cargo.toml b/Cargo.toml index 01fbdcd..b3d8f4c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ edition = "2021" build = "src/build.rs" name = "cicada" -version = "0.9.39" +version = "0.9.40" authors = ["Hugo Wang "] description = "A simple Bash-like Unix shell." diff --git a/src/parsers/parser_line.rs b/src/parsers/parser_line.rs index c9a18a8..ef7688c 100644 --- a/src/parsers/parser_line.rs +++ b/src/parsers/parser_line.rs @@ -50,7 +50,7 @@ pub fn line_to_cmds(line: &str) -> Vec { 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('\\'); @@ -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); } }