hella_shell is a simple command line interpreter based on the first Unix shell 'sh', created by Ken Thompson in 1971. hella_shell is intentionally minimalistic and contains functionality for only the most basic shell tasks - accepting input, parsing the input into a command and its arguments, and executing that input. Error checking is simple and follows Bash conventions.
The purpose of the simple shell project is to understand:
- how a shell works
- PID and PPIDs
- how processes are created
- the three prototypes of
main - how the shell uses the
PATHto find and execute programs - the
EOF/"end-of-file" condition
- Must follow Betty style and document guidelines
- Allowed editors:
vi,vim,emacs - Must have a
README.mdfile - All header files must be include guarded
- No more than 5 functions per files
- AUTHORS - list of contributors
- check_helpers.c - helper functions that check for builtins
exit_check- checks if user_input isexitblank_check- checks if user_input is\nenv_check- checks if user_input isenv
- env_helpers.c - helper functions related to PATH and other environment variables
get_path_count- gets count of path partsget_path_array- tokenizes path to 2d arrayfind_path- finds and checks path for given commandprint_env- shell builtin that prints current environment
- error_helpers.c - helper functions that print appropriate error messages
command_error- command not found errorexec_error- command could not execute erroraccess_error- user does not have permission to execute commandexit_error- user has entered an invalid exit code
- fork_wait_exec.c - process and execution function
- memory_helpers.c - helper functions related to memory management
free_array- 2D array freeing function
- man_1_simple_shell - manual page
- number_helpers.c - helper functions pertaining to integers
_atoi- turns a numerical string into an integerprint_number- prints an integer to standard output
- parse_input.c - command and argument parsing function
- shell.c - main function
- shell.h - header file
- string_helpers.c - helper functions pertaining to string handling
_strlen- finds length of a string_strcmp- compares two strings_strdup- duplicates two strings (including memory management)_putchar- writes a single character to standard output
gcc -Wall -Wextra -Werror -pedantic *.c -o hsh
GCC 4.8.4 or later only
~/me$ ./hsh
hella_shell$ echo & the bunnymen
& the bunnymen
hella_shell$ pwd
/home/me/hella_shell
hella_shell$
hella_shell$ exit
~/me$~/me$ cat hella_shell.txt | ./hsh
got me feelin' hella shell so let's just keep on codin'
~/me$At this time, there are no known bugs.
Lizzie Turner | GitHub | Twitter Omar Contreras | GitHub | Twitter
hella_shell is open source and free to download and use