Skip to main content

cd

Function cd 

Source
pub async fn cd(ctx: CommandContext) -> CommandResult
Expand description

Execute the cd command

Mirrors POSIX sh/bash semantics so that shell scripts translate directly:

  • cd -> change to $HOME (or $USERPROFILE on Windows)
  • cd ~/cd ~/x -> tilde expands to $HOME
  • cd - -> change to $OLDPWD and print the new directory (like sh)
  • cd <dir> -> change to (relative paths resolve against the current working directory, or the cwd option)

Like a real shell, a successful cd updates the PWD and OLDPWD environment variables and changes the process directory so that subsequent commands (virtual or real) observe the new location.