Holberton School project incorporating all topics covered so far about learning C programming.
The hsh is a simplified command line interpreter for the system, or shell, an aproach to the first Unix shell written by Ken Thompson. In that sence it reads lines from either a file or the terminal, interprets them, and generally executes other commands. Simple_shell is desgined to run on the linux environment.
- AUTHORS - List of contributors to this repository
- man_1_simple_shell - Manual page for the simple_shell
- shell.h - program header file
- main.c - Main shell file function
- buffer_handling.c - functions related to store input
count_buffer
- Counts the number of words in a stringcreate_buffer
- creates a string with a given bidimensional arraycreate_exec_buffer
- creates a bidimensional array of strings- signal_handler.c - functions related to reading signals
signal_handler
- handles signals from keyboard interruptseof
- end of file declarationprint_error
- prints & perror the error msgprint_error_code
- prints & write the error msg- memory_funcs.c - memory allocation functions
malloc_checked
- allocates memory using malloc_realloc
- reallocates a memory block using malloc and free._memset
- fill memory with a constant byte_memcpy
- copies memory areafree_list
- Function that frees a list- string_funcs.c - functions related to string manipulation
_strlen
- return the length of the string_strcpy
- Copy the stringsrc
todest
_strcmp
- Compare two strings_strncmp
- Compare n bytes of two strings- string_funcs_2.c - functions related to string manipulation
_strtok
- Split a string up into tokens_strtok_r
- extract tokens from strings & hold index ptr (thread safe).- string_funcs_3.c - functions related to string manipulation
_strchr
- locate character in a string_strcspn
- search a string for a set of bytes_strspn
- gets length of a prefix substring_strdup
- duplicate a specific number of bytes from a string_strbrk
- search a string for any of a set of bytes- string_funcs_4.c - functions related to string manipulation
_putchar
- writes the character c to stdout_puts
- writes the character c to stdoutword_count
- counts words given a char delimiter_strncat
- concatenates two strings by n bytesstr_concat
- function that concatenates two strings- struct_funcs.c - functions related to struct manipulation
add_node
- function that adds a nodeprint_list
- Function to print a simple list- parser.c - lexical analyzer (lexer, tokenizer, scanner)
lexer
- Scan for standard input from terminalvalidate_command
- Function that validates the commandget_route
- Function that brings the route of a commandvalidate_buffer
- Function that validates if buffer brings exit or env- cpy_funs.c - functions related to environment
_getenv
- get an environment variableget_dir
- get current working directoryget_path
- return the pathnameenv
- writes environ
simple_shell is designed to run in the Ubuntu 14.04 LTS
linux environment and to be compiled using the GNU compiler collection v. gcc 4.8.4
with flags-Wall, -Werror, -Wextra, and -pedantic.
Only allowed to use the following functions and system calls:
access (man 2 access)
chdir (man 2 chdir)
close (man 2 close)
closedir (man 3 closedir)
execve (man 2 execve)
exit (man 3 exit)
fork (man 2 fork)
free (man 3 free)
fstat (man 2 fstat)
getcwd (man 3 getcwd)
getline (man 3 getline)
kill (man 2 kill)
lstat (man 2 lstat)
malloc (man 3 malloc)
open (man 2 open)
opendir (man 3 opendir)
perror (man 3 perror)
read (man 2 read)
readdir (man 3 readdir)
signal (man 2 signal)
stat (man 2 stat)
strtok (man 3 strtok)
wait (man 2 wait)
waitpid (man 2 waitpid)
wait3 (man 2 wait3)
wait4 (man 2 wait4)
write (man 2 write)
_exit (man 2 _exit)
Clone this repository onto your local machine, compile with the flags listed below
git clone https://github.com/VIDMORE/simple_shell.git
cd simple_shell
gcc -Wall -Werror -Wextra -pedantic *.c -o hsh
Run the simple shell
./hsh
then you can use commands like in sh
$ ls -al
To exit the simple shell
exit
"or in keyboard Ctrl + D"
"21 Savage - a lot ft. J. Cole" Please report any issues to the authors.
David Alejandro Corredor Mora vidmor@gmail.com
Santiago Efrain Martinez Leon sntgmtnz@gmail.com
simple_shell is open source and therefore free to download and use without permission.