Skip to content

Commit

Permalink
Support cd command
Browse files Browse the repository at this point in the history
  • Loading branch information
nexryai committed Jul 12, 2024
1 parent a26e021 commit a5472a9
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit a5472a9

Please sign in to comment.