diff --git a/crates/deno_task_shell/src/shell/commands/cd.rs b/crates/deno_task_shell/src/shell/commands/cd.rs index ea4f1ed..b4e1c3a 100644 --- a/crates/deno_task_shell/src/shell/commands/cd.rs +++ b/crates/deno_task_shell/src/shell/commands/cd.rs @@ -38,7 +38,13 @@ impl ShellCommand for CdCommand { } fn execute_cd(cwd: &Path, args: Vec) -> Result { - let path = parse_args(args)?; + // create a new vector to avoid modifying the original + let mut args = args; + if args.is_empty() { + // append `~` to args + args.push("~".to_string()); + } + let path = parse_args(args.clone())?; let new_dir = if path == "~" { dirs::home_dir() .ok_or_else(|| anyhow::anyhow!("Home directory not found"))?