A small Unix-like shell written in C, supporting built-in commands, external
program execution, and a 10-entry command history with !n recall.
- Custom prompt:
user@miniShell$[YYYY-mm-dd HH:MM:SS] - Interactive loop with whitespace tokenization (tabs, multiple spaces)
- External commands via
fork()+execvp()+waitpid()(absolute and relative paths supported) - Built-in commands implemented in-process (no
exec):cd [dir]— change directory (chdir)pwd— print working directory (getcwd)history— list the last 10 commands!n— re-run the n-th command fromhistoryexit— leave the shell
- Error handling: command not found, wrong arguments, permission denied,
fork()failure - Clean exit on EOF (Ctrl+D); zombie processes are reaped
make
./minishell
Requires gcc (C11) and a POSIX system. No third-party dependencies.
->pwd
/home/user
->echo hello world
hello world
->history
1 pwd
2 echo hello world
3 history
->!2
hello world
- No pipes, redirection, or background jobs
- No quoting, globbing, or variable expansion
pwdis limited to paths shorter than 100 characters
| File | Purpose |
|---|---|
main.c |
REPL loop and buffers |
basicFunction.c/.h |
prompt, tokenizing, command dispatch |
commands.c/.h |
built-in command table |
queue.c/.h |
10-entry history ring buffer |