A small C program that builds shell-style command arguments from user input. Written on macOS using Clang and LLDB.
This project currently implements command parsing, basic command execution, signal handling, and core built-ins.
- Reads input using
fgets() - Removes the trailing newline
- Tokenizes the command line using
strtok() - Constructs an argv-style array
char *my_argv[] - Executes commands by spawning child processes with
fork()andexecvp() - Supports built-in commands (
cdandexit)
Input: ls -l /tmp
Output: Runs the ls command and prints directory contents.
To compile and run the project locally on macOS:
# Compile with Clang
clang -Wall -Wextra -g sh.c -o sh
# Run the program
./sh- Process execution with
fork()andexecvp() - Built-in commands (
cd,exit) - Pipelines using
pipe() - I/O redirection using
dup2() - Signal handling (
SIGINT)