Step 5 - Challenge: Implement Builtin Commands
Step 5 - Challenge: Implement Builtin Commands
Build Your Own Shell (Python Edition)
Step 1 - Create The Simplest Possible Command Line Shell
Step 1 - Create The Simplest Possible Command Line Shell
Step 2 - Challenge: Handle Multiple Commands
Step 2 - Challenge: Handle Multiple Commands
Step 3 - Non Existent Commands
Step 3 - Non Existent Commands
Step 4 - External Commands With Arguments
Step 4 - External Commands With Arguments
Step 7 - Handling Signals
Step 7 - Handling Signals
Conclusion
Conclusion
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
%