simple_shell

UNIX command line interpreter written in C implementing process forking, path se

simple_shell: UNIX Command Line Interpreter in C

A standards-compliant UNIX command language interpreter written in C, implementing interactive and non-interactive command execution, process lifecycle management, path resolution, and builtin commands.

graph TD
    Input[Standard Input / User Command] --> Reader["my_getline() Input Buffer"]
    Reader --> Tokenizer[Lexer & Command Tokenizer]
    Tokenizer --> Parser[Command Node & Argument Builder]
    Parser --> BuiltinCheck{Is Builtin?}
    BuiltinCheck -->|Yes: exit, env, cd| ExecBuiltin[Internal Command Dispatcher]
    BuiltinCheck -->|No| PathResolver["PATH Environment Search ('my_path')"]
    PathResolver --> Fork["fork() Child Process"]
    Fork --> Exec["execve() Binary Execution"]
    Exec --> Wait["waitpid() Parent Process Sync"]

Core Subsystems

simple_shell mimics the core operational behavior of POSIX shells such as sh and dash:

Subsystem Breakdown

Compilation & Usage

Interactive Mode

gcc -Wall -Werror -Wextra -pedantic -std=gnu89 *.c -o hsh
./hsh
$ /bin/ls -la
$ exit

Non-Interactive Mode

echo "/bin/ls" | ./hsh