This project is a basic Linux shell implementation called sish
. It supports:
- Executing system commands
- Built-in commands:
cd
,exit
,history
- A command history buffer (last 100 commands)
- Multi-process Unix-style pipes (
|
)
sish.c
: Main source codehist100
: Input file to test if only 100 commands are stored in history (from stdin redirection)
gcc sish.c -o sish -Wall -Werror -std=gnu99
- Prompts with:
sish>
- Tokenizes input and executes basic Linux commands (e.g.,
ls
,pwd
,echo
) - Uses
fork()
+execvp()
Command | Description |
---|---|
exit |
Exit the shell |
cd [dir] |
Change directory using chdir() |
history |
Show the last 100 commands |
history -c |
Clear all command history |
history [n] |
Execute command at offset n |
- Executes commands with pipes like
ls | wc
- Supports multi-level pipes like
cat hist100 | grep cat | wc
Please refer to the file testcases.txt
for all test case inputs and expected behaviors.
Ensure you test:
- Basic command execution (
ls
,pwd
,echo
, etc.) - Built-in commands (
cd
,exit
,history
) - History overflow and offset execution
- Piped commands (
ls | wc
,cat hist100 | grep ... | wc
)
You can also run:
./sish < hist100