Simple shell project is a Holberton School project replicating a basic command line interpreter(
shell) that executes commands by evaluating user input.
shell.h - header file including macros , prototypes, & struct main.c - takes user command and executes if file exists tokens.c - splits a character string into 2d array of tokens add_node_end.c - adds a new node at the end of a listint_t list. check_path.c - concat user input to values of linked list execute.c - executes the command get_path.c - tokenize PATH and store values in a linked list isbuiltin.c - searches for builtin and finds it's corresponding handling fcn to_free.c - frees lists
free_linked(list_t *head, char *buffer)
- frees a linked list and bufferfree_2darray(char **array)
- frees a 2D array
run_path.c - store PATH in linked list and check if usr command exist
Helper Functions: helpers.c - helper functions:
run_prompt(void)
- prints prompt to stdout_memset(char *buffer)
- fills memory with null bytesfile_stat(char *str)
- check whether file existscmd_error(char *filename)
signal_handle
- signal handler
strings.c - helper string functions:
_putstring(char *str)
_strlen(char *s)
_strcmp(char *s1, char *s2)
*_strcat(char *dest, char *src)
_strcpy(char *dest, char *src)
strings2. - more helper string functions_strncmp(char *s1, char *s2, int n)
_putchar(char c)
Simple shell currently support builtins env
and exit
as well as functions available in the environment variable, PATH. All programs were compile with gcc 4.8.4
in Ubuntu 14.05.5 LTS.
Clone simple_shell repository:
git clone https://github.com/jhuang10123/simple_shell.git
Compile program:
gcc -Wall -Wextra -Werror -pedantic *.c -o hsh
Holberton shell can then be invoked by running the executable hsh
To run in interactive mode, enter ./hsh
and a command once gree
ted by prompt.
To run in noninteractive mode, pipe command into this hsh: echo \ "ls -l" | ./hsh
To run a simple ls -l
command in interactive mode: ($) ls -l