Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
ryuichiueda committed Dec 31, 2023
1 parent 58766c4 commit 11fbf60
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/core/builtins/cd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ fn set_oldpwd(core: &mut ShellCore) {
}

fn change_directory(core: &mut ShellCore, args: &mut Vec<String>) -> i32 {
let path = utils::make_canonical_path(utils::make_absolute_path(core, &args[1]));
let path = utils::make_canonical_path(core, &args[1]);
if core.set_current_directory(&path).is_ok() {
core.vars.insert("PWD".to_string(), path.display().to_string());
0
Expand Down
3 changes: 2 additions & 1 deletion src/core/builtins/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ pub fn make_absolute_path(core: &mut ShellCore, path_str: &str) -> PathBuf {
absolute
}

pub fn make_canonical_path(path: PathBuf) -> PathBuf {
pub fn make_canonical_path(core: &mut ShellCore, path_str: &str) -> PathBuf {
let path = make_absolute_path(core, path_str);
let mut canonical = PathBuf::new();
for component in path.components() {
match component {
Expand Down

0 comments on commit 11fbf60

Please sign in to comment.