From a5472a954ef6b741e83221a344be91ca67ce9263 Mon Sep 17 00:00:00 2001 From: nexryai Date: Fri, 12 Jul 2024 14:51:09 +0900 Subject: [PATCH] Support cd command --- src/main.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index c61bf6f..db22f4d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -16,7 +16,15 @@ fn exec(command: &str) { use std::process::Command; let mut parts = command.split_whitespace(); let command = parts.next().unwrap(); - let args = parts; + let mut args = parts; + + // cdコマンドの場合set_current_dirを使う + if command == "cd" { + let dir = args.next().unwrap(); + std::env::set_current_dir(dir).expect("Failed to change directory"); + return; + } + let status = Command::new(command) .args(args) .status()