This project is a simple UNIX command line interpreter, often referred to as a "shell." It provides basic functionality for users to interact with their system through a command-line interface. This README file will guide you through the features and usage of this simple shell.
- Display a prompt and wait for the user to type a command. A command line always ends with a new line.
- The prompt is displayed again each time a command has been executed.
- The shell can parse command lines with arguments.
- If an executable cannot be found, it prints an error message and displays the prompt again.
- The shell handles various errors gracefully and provides informative error messages to the user.
- Handles the "end of file" condition (Ctrl+D) to exit the shell.
- Handles commands that are part of the PATH environment variable, allowing users to execute common system commands.
- Supports built-in commands such as
exit
andenv
.
- Ignores comments in the command line (lines starting with
#
), making it easy to add comments to scripts.
To get started with this simple shell, follow these steps:
-
Clone the project repository to your local machine:
git clone https://github.com/your-username/simple-shell.git
-
Change your current directory to the project folder:
cd simple-shell
-
Compile the shell:
gcc main.c -o hsh
-
Run the shell:
./hsh
Once the shell is running, you can enter commands and interact with your system using the simple shell. Here are some examples:
-
Execute a system command:
ls -l
-
Run a built-in command:
exit
-
Use comments in your script:
echo "Hello, world!" # This is a comment
The simple shell supports the following built-in commands:
exit
: Exit the shell.env
: Display the current environment variables.
To use a built-in command, simply enter the command at the shell prompt.
The shell provides detailed error messages for various situations, including:
- Command not found.
- Invalid input.
- File or directory not found.
The error messages are designed to help you understand and resolve issues with your commands.
Enjoy using the Simple Shell! If you have any questions or encounter issues, please feel free to reach out for assistance.