Simple Shell is a basic UNIX command line interpreter developed as a collaborative project. This project involves implementing essential features of a shell in C, adhering to the requirements and constraints typical of a UNIX environment.
- Name: Paschal Ugwu
- Email: ugwupaschal@gmail.com
This project implements a simple UNIX command interpreter, commonly known as a shell. It covers fundamental aspects of shell functionality, including command execution, environment management, and built-in commands.
- Interactive Mode: Prompts the user for commands and executes them.
- Non-Interactive Mode: Executes commands from a file or standard input.
- Command Execution: Executes commands located in directories specified by the PATH environment variable.
- Built-in Commands: Supports built-in commands like
exit
andenv
.
$ ./hsh
($) /bin/ls
($) exit
$ echo "/bin/ls" | ./hsh
$ cat commands.txt | ./hsh
Compile the shell with:
gcc -Wall -Werror -Wextra -pedantic -std=gnu89 *.c -o hsh
Ensure to use gcc
with the provided options to meet project requirements.
- Objective: Ensure all code adheres to the Betty style guide.
- Implementation: Verify code style using
betty-style.pl
andbetty-doc.pl
.
- Objective: Implement a basic shell that:
- Displays a prompt and waits for user input.
- Executes simple commands without arguments.
- Handles "end of file" (Ctrl+D) and errors.
- Limitations: No support for advanced features like pipes, redirections, or multiple commands.
- Objective: Extend the shell to handle command lines with arguments.
- Enhancements: Parse and execute commands with arguments.
- Objective: Integrate PATH handling.
- Enhancements: Search for commands in directories specified by the PATH environment variable.
- Objective: Implement the
exit
built-in command. - Enhancements: Support exiting the shell using the
exit
command.
- Objective: Implement the
env
built-in command. - Enhancements: Display the current environment variables.
- Simple shell 0.1.1: Implement a custom
getline
function using a buffer. - Simple shell 0.2.1: Implement custom tokenization without
strtok
. - Simple shell 0.4.1: Handle arguments for the
exit
built-in command. - setenv, unsetenv: Implement
setenv
andunsetenv
built-ins for environment variable management. - cd: Implement the
cd
built-in command. - ;: Handle command separator
;
. - && and ||: Implement logical operators
&&
and||
.
- Unix shell: Wikipedia
- Thompson shell: Wikipedia
- Ken Thompson: Wikipedia
- Shell Programming Guide: Everything you need to know to start coding your own shell
Test the shell in both interactive and non-interactive modes. Ensure it handles common edge cases and adheres to expected behavior as outlined in the tasks.
This project was developed as part of the ALX Software Engineering curriculum. Special thanks to the ALX community for their guidance and support.