simple_shell is a basic UNIX-style command-line interpreter written in C. It replicates some of the core functionalities of the standard Unix shell, including executing built-in and external commands, input/output redirection, and piping.
- Execute built-in commands (
exit,env) - Execute external commands in the system’s
$PATH - Support for input (
<) and output (>) redirection - Simple piping (
|) between commands - Works in both interactive and non-interactive modes
- GCC (GNU Compiler Collection)
- A UNIX-like operating system (Linux, macOS, etc.)
-
Clone the repository:
git clone https://github.com/sanzamcmillian/simple_shell.git
-
Navigate into the project directory:
cd simple_shell -
Compile the shell:
gcc -Wall -Werror -Wextra -pedantic *.c -o hsh
-
To start the shell, run:
./hsh
-
Then you can start typing commands, for example:
$ ls -la $ echo "Hello, World!" $ cat input.txt > output.txt $ grep "word" file.txt | sort
-
To exit the shell, use:
exit
exit: Exit the shellenv: Print environment variables
main.c: Entry point, main loopbuiltin.c: Built-in command implementationsgetline.c: Customegetlineimplementationinit.c: initialization logicnon_inter.c: Non-interactive mode handlerutil.c: Helper and utility functionsshell.h: Header file with funtction declarations and macros
Sanele Skhosana
This project is open-source and available under MIT License.