This repository contains my solution for the "Build Your Own Shell" Challenge.
In this challenge, I built a POSIX-compliant shell capable of interpreting shell commands, running external programs, and handling builtin commands like cd, pwd, echo, and more. Along the way, I learned about shell command parsing, REPLs, and the implementation of builtin commands.
The base stages required building the core of the shell to support basic commands and functionality.
I have successfully completed the implementation of the core functionality of the shell across multiple stages. This includes:
-
Command Parsing:
- Parses and interprets user input effectively, supporting arguments and options.
-
Builtin Commands:
exit: Exit the shell with a specified status code.echo: Print text to the terminal.type: Identify commands as built-in or external.pwd: Displays the current working directory.cd: Supports navigation using:-- Absolute paths, e.g.,
/usr/local/bin - Relative paths, e.g.,
./,../,./dir - The
~character, representing the user's home directory.
- Absolute paths, e.g.,
-
External Program Execution:
- Runs programs located in directories specified by the
PATHenvironment variable.
- Runs programs located in directories specified by the
- Clone the repository:
git clone https://github.com/HackerKing5128/codecrafters-shell-java.git
- Navigate to the project directory:
cd codecrafters-shell-java - Run the shell program:
./your_program.sh
- Test with commands:
- Try
cd,pwd,echo Hello, ortype ls
- Try
You can view the entry point of the implementation in
src/main/java/Main.java.