This is a simple shell project developed as part of ALX software engineering program. The goal of this project is to create a basic shell that mimics the functionality of a Linux shell.
Unless specified otherwise, your program must have the exact same output as sh
(/bin/sh
) as well as the exact same error output.
The only difference is when you print an error, the name of the program must be equivalent to your argv[0]
(See below)
Example of error with sh
:
$ echo "qwerty" | /bin/sh
/bin/sh: 1: qwerty: not found
$ echo "qwerty" | /bin/../bin/sh
/bin/../bin/sh: 1: qwerty: not found
$
Same error with your program hsh:
$ echo "qwerty" | ./hsh
./hsh: 1: qwerty: not found
$ echo "qwerty" | ./././hsh
./././hsh: 1: qwerty: not found
$
Your shell should work like this in interactive mode:
$ ./hsh
($) /bin/ls
hsh main.c shell.c
($)
($) exit
$
But also in non-interactive mode:
$ echo "/bin/ls" | ./hsh
hsh main.c shell.c test_ls_2
$
$ cat test_ls_2
/bin/ls
/bin/ls
$
$ cat test_ls_2 | ./hsh
hsh main.c shell.c test_ls_2
hsh main.c shell.c test_ls_2
$
access
/
chdir
/
close
/
closedir
/
execve
/
exit
/
_exit
/
fflush
/
fork
/
free
/
getcwd
/
getline
/
getpid
/
isatty
/
kill
/
malloc
/
open
/
opendir
/
perror
/
read
/
readdir
/
signal
/
stat
/
lstat
/
fstat
/
strtok
/
wait
/
waitpid
/
wait3
/
wait4
/
write
/
Program will be compiled this way:
gcc -Wall -Werror -Wextra -pedantic -std=gnu89 *.c -o hsh
- Create a loop to continuously accept user commands.
- Parse the user input to identify the command and its arguments.
- Execute the command with execve() in a child process created using fork().
- Handle non fullpath command \
- Process built-in commands such as exit, cd, env ...etc
... MORE STEPS WILL BE ADDED AS WE PROGRESS IN THE PROJECT
shell.h
— header file that contains all used functions and custom struct types.main.c
— contains the primary function of our shell, serving as the program's entry point and featuring the foundational code for our shell's operation.command.c
— function to perform operations on the shell command.arguments.c
— functions for handling and parsing command-line arguments passed to our custom shell.builtin.c
— contains functions to handle builtin commands.strings.c
— this file encompasses all the functions to deal with strings.lists.c
— contains all function to manipulate linked lists.environment.c
— functions for manage and interact with the environment variables, including setting, getting, or modifying environment settings.errors.c
— handle error messages.cleanup.c
— includes functions responsible for cleaning up resources, ensuring proper termination and avoiding memory leaks._getline.c
— custom implementation of the built-in getline function._strtok.c
— personalized version of the native strtok string tokenization function.
Hamza Dazia — https://github.com/HamzaDazai
Ouadia EL-Ouardy — https://github.com/EL-OUARDY