diff --git a/Cargo.lock b/Cargo.lock index 58bc594..d02fc67 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -260,6 +260,7 @@ name = "deno_task_shell" version = "0.17.0" dependencies = [ "anyhow", + "dirs", "futures", "glob", "os_pipe", diff --git a/crates/deno_task_shell/Cargo.toml b/crates/deno_task_shell/Cargo.toml index 5830b1f..4d192a0 100644 --- a/crates/deno_task_shell/Cargo.toml +++ b/crates/deno_task_shell/Cargo.toml @@ -26,6 +26,7 @@ serde = { version = "1", features = ["derive"], optional = true } thiserror = "1.0.58" pest = "2.6.0" pest_derive = "2.6.0" +dirs = "5.0.1" [dev-dependencies] parking_lot = "0.12.1" diff --git a/crates/deno_task_shell/src/grammar.pest b/crates/deno_task_shell/src/grammar.pest index 0c7e8b3..600cedd 100644 --- a/crates/deno_task_shell/src/grammar.pest +++ b/crates/deno_task_shell/src/grammar.pest @@ -31,7 +31,7 @@ QUOTED_PENDING_WORD = ${ ( UNQUOTED_ESCAPE_CHAR = ${ ("\\" ~ "$" | "$" ~ !"(" ~ !VARIABLE) | "\\" ~ (" " | "`" | "\"" | "(" | ")")* } QUOTED_ESCAPE_CHAR = ${ "\\" ~ "$" | "$" ~ !"(" ~ !VARIABLE | "\\" ~ ("`" | "\"" | "(" | ")" | "'")* } -UNQUOTED_CHAR = ${ ("\\" ~ " ") | !("~" | "(" | ")" | "{" | "}" | "<" | ">" | "|" | "&" | ";" | "\"" | "'" | "$") ~ ANY } +UNQUOTED_CHAR = ${ ("\\" ~ " ") | !("(" | ")" | "{" | "}" | "<" | ">" | "|" | "&" | ";" | "\"" | "'" | "$") ~ ANY } QUOTED_CHAR = ${ !"\"" ~ ANY } VARIABLE = ${ (ASCII_ALPHANUMERIC | "_")+ } diff --git a/crates/deno_task_shell/src/shell/commands/cd.rs b/crates/deno_task_shell/src/shell/commands/cd.rs index 54ae007..ea4f1ed 100644 --- a/crates/deno_task_shell/src/shell/commands/cd.rs +++ b/crates/deno_task_shell/src/shell/commands/cd.rs @@ -39,7 +39,12 @@ impl ShellCommand for CdCommand { fn execute_cd(cwd: &Path, args: Vec) -> Result { let path = parse_args(args)?; - let new_dir = cwd.join(&path); + let new_dir = if path == "~" { + dirs::home_dir() + .ok_or_else(|| anyhow::anyhow!("Home directory not found"))? + } else { + cwd.join(&path) + }; let new_dir = match new_dir.parse_dot() { Ok(path) => path.to_path_buf(), // fallback to canonicalize path just in case