This project is a Unix command line interpreter, or simple shell, written in C as part of the Holberton School low-level programming curriculum.
It aims to recreate basic behavior of a shell such as /bin/sh, including executing commands and handling built-ins like exit and env.
- Display a prompt and wait for user input
- Execute commands with arguments
- Handle commands found in the
PATH - Support for interactive and non-interactive modes
- Handle built-ins:
exit: exits the shellenv: prints current environment variables
- Error handling: command not found, memory errors, fork failures, etc.
accesschdircloseexecveexit,_exitforkfreegetcwdgetlineisattymallocopenperrorreadsignalstatwaitwrite- etc.
- Code must follow Betty style
- No memory leaks allowed
- Maximum 5 functions per file
- No use of global variables
- Header files must be include guarded
README,AUTHORS, and man page- Betty-compliant code
- Simple shell 0.1: basic execution
- Simple shell 0.2: with arguments
- Simple shell 0.3: handle
PATH - Simple shell 0.4:
exitbuilt-in - Simple shell 1.0:
envbuilt-in
Clone this repository into your local environment :
git clone https://github.com/QuentinC26/holbertonschool-simple_shell.git- Then navigate to the project folder :
cd holbertonschool-simple_shellThe shell is compiled using:
gcc -Wall -Werror -Wextra -pedantic -std=gnu89 *.c -o hsh- Exécutez ensuite le programme compilé :
./hsh$ ./hsh
($) ls -l
total 0
-rw-r--r-- 1 user user 0 Apr 13 17:35 file1
($) exit$ echo "ls -l" | ./hsh
total 0
-rw-r--r-- 1 user user 0 Apr 13 17:35 file1.
├── AUTHORS
├── README.md
├── man_1_simple_shell
├── shell.h
├── main.c
├── prompt.c
├── exec_cmd.c
├── read_line.c
├── utils.c
├── path_handler.c
├── tokenize_line.c
├── builtins.c
└── ...| Command | Description |
|---|---|
exit |
Exit the shell |
env |
Print the environment variables |
You can test your shell using scripts or manual command entry.
For example :
echo "/bin/ls" | ./hsh
cat test_commands.txt | ./hshWhere test_commands.txt contains :
ls -l
env
exitYou can read the custom man page using:
man ./man_1_simple_shell- Handle comments with
# - Support for
;separators - Built-ins:
cd,help, etc. - Alias support
- Command history