Holberton School
simple_shell is a command line interpreter, or shell, in the tradition of the first Unix shell written by Ken Thompson in 1971. This shell is intentionally minimalistic, yet includes the basic functionality of a traditional Unix-like command line user interface.
-
[Function] :
- main - main function with shell body
- exevc - recreate execve funtcion
- exit - exit the simple shell
- memcpy - recreate memcpy funtcion
- prompt - recreate prompt funtcion
- realloc - recreate realloc funtcion
- echo_command - implementation of echo command in shell
- node_function - Add a node a the end of the linked list
- _atoi - Convert the first number of a str to an interger.
- execut_command - Test and execute a command
- sep_to_space - Change \t and \r into a space
- signal_handler - Catch a Ctrl - C and disable him
- _getline - Check the number of characters on a specific line
-
[PATH function] :
- init_path - Initialise a linked list of the PATH contain
- search_command_path - Search if a command is in the PATH
-
[str function] :
-
[check] :
- check_built_in - check all built-in command before the first fork
- check_user_input - Put a '\0' at the end of the input and check if there is any comment
-
[environement function] :
-
[free memory file] :
- free_all - free all malloc / realloc / buffer
-
[Header file] :
- shell.h - Header file contain all prototype / standart library / and structure
-
[Helping files] :
- uses the PATH
- implements builtins
- handles command line arguments
- custom strtok function
- uses exit status
- shell continues upon Crtl+C (^C)
- handles comments (#)
- handles ;
- custom getline type function
- handles && and ||
- aliases
- exit
- env
- setenv
- unsetenv
- cd
- help
Run the executable in your terminal after compiling:
gcc -Wall -Werror -Wextra -pedantic -std=gnu89 shell.h *.c -o hsh
./hsh
exemple:
./hsh
$ # type you command here
$ ls
bermuda_triangle.c I_hate_simple_shell.c README.md
$ echo $$
24413
$ env
SHELL=/bin/bash
COLORTERM=truecolor
TERM_PROGRAM_VERSION=1.62.3
LC_ADDRESS=C.UTF-8
LC_NAME=C.UTF-8
LC_MONETARY=C.UTF-8
PWD=/home/vagrant/Simple_shell
LOGNAME=vagrant
XDG_SESSION_TYPE=tty
VSCODE_GIT_ASKPASS_NODE=/home/vagrant/.vscode-server/bin/ccbaa2d27e38e5afa3e5c21c1c7bef4657064247/node
MOTD_SHOWN=pam
...
$ exit # leave de shell ctrl C hase disable