Simple Shell is a minimal command-line interpreter developed by Federico Paganini and Bruno Barrera.
- Interactive Mode with a custom prompt (
#cisfun$). - Handling of extra spaces and empty commands.
- Tokenization of command and arguments.
- Search for executables in the
$PATHenvironment variable. - Support for absolute and relative paths.
- Clear error messages when a command is not found or cannot be executed.
- POSIX-compliant operating system (e.g., Linux, macOS).
- GCC (or any C-compatible compiler).
Clone the repository and navigate into it:
$ git clone https://github.com/yourusername/simple_shell.git
$ cd simple_shellCompile the project with recommended flags:
$ gcc -Wall -Werror -Wextra -pedantic -std=gnu89 *.c -o simple_shellLaunch the shell executable:
$ ./simple_shellYou will see the prompt:
#cisfun$To exit the shell, you can:
- Type
exitand press Enter. - Press Ctrl+D (EOF).
Below is a diagram that explains the main flow of the application:
#cisfun$ /bin/ls
Path: /bin/ls#cisfun$ ls
Path: /usr/bin/ls- gates_of_shell.c: Contains
main(), which runs the shell loop. - input_handler.c: Displays the prompt, reads the input line, and splits it into tokens.
- interpreter.c: Determines if the command includes a path or needs to be searched in
$PATH, and validates it. - utils.c: Helper functions to count words and free allocated memory.
- shell.h: Header file with library includes and function prototypes.
- Initialization:
main()sets up structures and enters an infinite loop. - Prompt: If in interactive mode, displays
#cisfun$. - Read Input:
get_line()reads the entire input line. - Tokenize:
tokenize_line()trims extra spaces and creates an array of arguments. - Interpret:
interpreter()checks for a provided path or searches directories in$PATH. - Result: Prints the absolute path of the executable or an error message.
- Loop: Continues until receiving
exitor EOF.
- Federico Paganini
- Bruno Barrera
