Ata Berke Göktekin 80277
A Unix-style interactive shell implemented in C for COMP 304 Assignment 1.
GitHub:
https://github.com/AtaGoktekin/shell-ish
gcc -o shell-ish shellish-skeleton.c
./shell-ishShell-ish executes standard Linux commands by manually resolving the PATH environment variable using execv() (not execvp()).
ls -la
mkdir test
date
gcc -o hello hello.cBackground execution with & — shell returns to prompt immediately:
sleep 10 &
# [background] PID: 12345Output redirection (truncate):
ls -la >output.txtOutput redirection (append):
ls >>output.txtInput redirection:
cat <output.txtNote: No space between redirection symbol and filename (e.g.
>file.txtnot> file.txt)
Piping — single and chained:
ls -la | grep shell
ls -la | grep shell | wc
cat /etc/passwd | cut -d : -f 1,6Reads lines from stdin and prints specified fields. Implemented in C.
Options:
-d <char>or--delimiter <char>— field delimiter (default: TAB)-f <list>or--fields <list>— comma-separated list of field indices (1-based)
cat /etc/passwd | cut -d : -f 1,6
# root:/root
# bin:/bin
# ...
echo -e "a\tb\tc" | cut -f 2
# bSimple multi-user chat using named pipes under /tmp/chatroom-<roomname>/.
chatroom <roomname> <username>- Creates the room folder if it doesn't exist
- Creates a named pipe for the user
- Receives messages from others continuously (reader child process)
- Sends messages to all other users in the room
- Type
exitto leave the room
Example (open two terminals):
# Terminal 1:
chatroom comp304 ali
# Terminal 2:
chatroom comp304 mehmetSets a reminder that appears after a specified number of seconds.
remind <seconds> <message>Examples:
remind 10 tea time!After the specified time:
--------------------
REMINDER: tea time!
--------------------
How it works: remind forks a child process that calls sleep() for the given duration, then prints the message. The parent returns immediately so the shell stays responsive.
shellish/
├── shellish-skeleton.c # full shell implementation
├── README.md # this file
├── imgs/ # screenshots of each feature
│ ├── part1_exec.png
│ ├── part1_background.png
│ ├── part2_redirection.png
│ ├── part2_pipe.png
│ ├── part3_cut.png
│ ├── part3_chatroom.png
│ └── part3_remind.png
- Tested on macOS
cutis implemented as a shell builtin (not an external binary)chatroomusesmkfifofor named pipes under/tmp/remindusesfork+sleepto avoid blocking the shell
During the development of this readme and bugs on the project, ChatGPT was used for assistance in the following areas:
- Debugging compiler errors and warnings (e.g. implicit function declarations, buffer truncation warnings)
- Fixing the
termioscanonical mode issue in thechatroomcommand - Writing and formatting this README