A small UNIX command-line interpreter written in C, modelled on sh. Built as a pair project with Ebube Ochemba during the ALX Software Engineering program.
- Shows a prompt and reads commands in a loop, in interactive mode or from a pipe (
echo "ls -l" | ./hsh) - Splits each line into the command and its arguments
- Searches the
PATHenvironment variable to find the program, then runs it withforkandexecveand waits for it to finish - Handles the
exitandenvbuilt-ins - Prints an error when a command isn't found
| File | What it does |
|---|---|
main.c |
Prompt loop and exit handling |
token_handling.c |
Splits input into arguments |
find_path.c |
Resolves a command through PATH |
executing.c |
fork / execve / wait |
builtin.c |
Built-in commands |
enviroment.c |
Environment variable helpers |
functions1.c, functions2.c |
Our own string functions (_strcmp etc.), since the project limited which standard library calls we could use |
gcc -Wall -Werror -Wextra -pedantic -std=gnu89 *.c -o hsh
./hshSee AUTHORS.