A super simple shell program written in C that allows users to input commands and executes them. This shell is designed to be a basic interactive command-line interface.
- Allowed editors: vi, vim, emacs
- Compilation on Ubuntu 20.4 LTS
- All files should end with a new line
- All files should follow the Betty style
- No memory leaks
- No more than 5 functions per file
- The header file should be include guarded
- Use system calls only when needed
To compile the project, your code will be compiled this way : gcc -Wall -Werror -Wextra -pedantic -std=gnu89 *.c -o shell
Function Limit: Keep each file concise with ... functions. Header Inclusion: Feature all function prototypes in main.h and include guards to avoid repetition. Side Note: No more than 3 malloc function provided for this project.
./shell The shell will display a prompt ($) where you can enter commands. It supports basic interactive command-line operations, handle the PATH and should be able to leave the function with exit.
- User-friendly prompt when running interactively.
- Handles commands entered by the user.
- Uses the getline function to read user input.
- Basic error handling and debugging information
The shell supports executing various commands available on the system. Enter a command and press Enter to execute it. Exit To exit the shell, use the Ctrl + D keyboard shortcut or enter the exit command. Debugging The program includes debugging information that can be enabled or disabled by modifying the print_debug function calls in the code.
Readability: Create a comprehensive README.md as the project's guide. Main Files: Use provided main.c files for testing but avoid including them in your final submission.
root@50c158e79d1b:~/holbertonschool-simple_shell# ./shell
$ ls
README.md execve.c main.h print_debug.c read_command.c shell.c
_getenv.c find_file_in_path.c man_page printenv.c shell tokenize_command.c
$ ls - a
ls: cannot access '-': No such file or directory
ls: cannot access 'a': No such file or directory
$ ls -a
. README.md find_file_in_path.c print_debug.c shell
.. _getenv.c main.h printenv.c shell.c
.git execve.c man_page read_command.c tokenize_command.c
$ ls -a
. README.md find_file_in_path.c print_debug.c shell
.. _getenv.c main.h printenv.c shell.c
.git execve.c man_page read_command.c tokenize_command.c
$ env
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
OLDPWD=/root
_=./shell
$ pwd
/root/holbertonschool-simple_shell
$ exit
root@50c158e79d1b:~/holbertonschool-simple_shell#
valgrind --leak-check=full ./shell
echo "/bin/ls" | valgrind --leak-check=full ./shell
echo " " | valgrind --leak-check=full --show-leak-kinds=all ./shell
echo "/bin/ls -l -a" | valgrind --leak-check=full ./shell
Refer to the man page for detailed information on how to use the shell function
man ./man_page
File | Description |
---|---|
read_command.c | Reads a line from the standard input and returns the input |
_getenv.c | Replicates the getenv function to be called in the find_file_in_path function |
tokenize_command.c | Tokenize a command line and returns an array of strings |
find_file_in_path.c | Looks for files in the PATH environment variable |
execve.c | Calls the two previous functions in order to execute a command |
print_debug.c | Handles error conditions |
shell.c | Main function meant to replicate a simple shell |
main.h | The header file that contains all the functions prototypes |
Authors : Simple Shell by Gilles and Benjamin