use shlex to mimic POSIX shell

This commit is contained in:
♥ Minnie ♥ 2025-06-08 09:06:01 +08:00
parent 4eddaade35
commit 40d73ecac0
Signed by: jasmine
GPG key ID: 8563E358D4E8040E
3 changed files with 12 additions and 2 deletions

9
Cargo.lock generated
View file

@ -5,3 +5,12 @@ version = 4
[[package]]
name = "rush"
version = "0.1.0"
dependencies = [
"shlex",
]
[[package]]
name = "shlex"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"

View file

@ -4,3 +4,4 @@ version = "0.1.0"
edition = "2024"
[dependencies]
shlex = "1.3.0"

View file

@ -16,8 +16,8 @@ pub fn get_input() -> String {
input
}
pub fn parse_input(s: &str) -> Vec<&str> {
s.split_whitespace().collect()
pub fn parse_input(s: &str) -> Vec<String> {
shlex::split(s).unwrap()
}
pub fn get_command(tokens: Vec<&str>) -> &str {