https://github.com/wiwichips/squish
Lightweight UNIX commandline shell for MacOS & Linux
https://github.com/wiwichips/squish
c linux mac pipe shell
Last synced: 10 months ago
JSON representation
Lightweight UNIX commandline shell for MacOS & Linux
- Host: GitHub
- URL: https://github.com/wiwichips/squish
- Owner: wiwichips
- Created: 2020-09-12T13:38:53.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2020-10-07T00:28:58.000Z (over 5 years ago)
- Last Synced: 2025-02-14T10:18:48.623Z (over 1 year ago)
- Topics: c, linux, mac, pipe, shell
- Language: C
- Homepage:
- Size: 113 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# SQUISH
Superior Quality Unbeatable Interprocess (communication) Shell, or "squish", is a shell that supports running processes, piping between processes, handle redirection, variable globbing, cd and exit.
## How to Compile and Run
```bash
make
./squish
```
## How errors are handled
* When entering a command that doesn't exist, squish will ouput "name: command not found".
* The exit status of the command will be outputted if running a single command.
## Piping algorithm
Processes are piped recursively backwards from the last command. The recursive base case is when there is only one command left to be exec'd.
For ex. ``p1 | p2 | p2`` can be represented as:
```
squish
/\
/ \
/\ p3
/ \
p1 p2
```
Pseudo-code follows as such:
```c
ipc (tokens, nTokens)
{
if ( nTokens == 1 ) {
fork new process
exec ( tokens[0] )
return
}
fork new process
if ( pid == 0 ) {
replace stdout with write end of pipe
ipc (tokens, --ntokens)
}
fork new process
if ( pid == 0 ) {
replace stdin with read end of pipe
exec ( tokens[nTokens] )
}
}
```
## File Structure
### Tokenization Files by AHW
squish_main.c
squish_run.c
squish_tokenize.c
### "Built-in" CD and exit
w_change_dir.c
w_exit.c
### Globbing
w_glob.c
### Piping and redirection
w_pipe.c
w_redirection.c
### Input parser
w_run.c
### Exec wrapper
w_run_command.c
## Works Cited
Some of the code is copied from the cis-3050 c examples from the linux.socs server. Wherever that is the case, a comment block will be included above the code snippit.