Step 5 - Challenge: Implement Builtin Commands
In this step your goal is to implement a builtin command (cd
) to change directories and pwd
, to get the current working directory. The cd
command has to be built in to the shell because it changes the internal state of the shell.
There are several other builtin commands you might have used regularly: cd
, exit
, export
, pwd
and unset
. You can find the full list using the man
pages for your shell - if you are not familiar with man
, try it now with the command man man
.
Once you’ve implemented cd and pwd you should be able to use them as so:
% ccsh
ccsh> ls
Cargo.lock Cargo.toml src target
ccsh> cd target
ccsh> ls
CACHEDIR.TAG debug
ccsh> pwd
/Users/john/dev/challenge-shell/ccsh/target
ccsh> cd ..
ccsh> pwd
/Users/john/dev/challenge-shell/ccsh
ccsh> exit
%