{"id":25391490,"url":"https://github.com/estnafinema0/rainbowshell","last_synced_at":"2026-02-11T00:35:48.742Z","repository":{"id":265545608,"uuid":"896231595","full_name":"estnafinema0/RainbowShell","owner":"estnafinema0","description":"A custom Unix shell written in C, featuring pipes, redirections, subshells, logical operators, and background jobs with a colorful startup message.","archived":false,"fork":false,"pushed_at":"2025-02-03T19:33:29.000Z","size":64,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-10T00:32:42.729Z","etag":null,"topics":["background-jobs","c-language","command-parsing","linux-terminal","shell-redirections","subshells","systems-programming","unix-shell"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/estnafinema0.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-11-29T20:44:37.000Z","updated_at":"2025-02-08T22:53:01.000Z","dependencies_parsed_at":null,"dependency_job_id":"4db2cbb6-81d9-4c8e-894d-6ac6b215ce29","html_url":"https://github.com/estnafinema0/RainbowShell","commit_stats":null,"previous_names":["estnafinema0/unix-shell"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/estnafinema0/RainbowShell","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/estnafinema0%2FRainbowShell","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/estnafinema0%2FRainbowShell/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/estnafinema0%2FRainbowShell/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/estnafinema0%2FRainbowShell/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/estnafinema0","download_url":"https://codeload.github.com/estnafinema0/RainbowShell/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/estnafinema0%2FRainbowShell/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29323934,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-11T00:34:26.354Z","status":"ssl_error","status_checked_at":"2026-02-11T00:34:09.494Z","response_time":65,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["background-jobs","c-language","command-parsing","linux-terminal","shell-redirections","subshells","systems-programming","unix-shell"],"created_at":"2025-02-15T15:42:59.804Z","updated_at":"2026-02-11T00:35:48.701Z","avatar_url":"https://github.com/estnafinema0.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# RainbowShell - Custom Unix Shell\n\nWelcome to **RainbowShell**, my educational but powerful custom Unix shell written in C. RainbowShell implements **pipes**, **redirections**, **logical operators**, **subshells**, and **background jobs** while also featuring a **rainbow/gradient** greeting message (builtes `color.h` library).\n\n\u003e **Note**: This is a project for the 3rd semester at CMC MSU (summarizing skills of systems programming, process handling, shell scripting concepts).\n\n---\n\n## Table of Contents\n\n- [RainbowShell - Custom Unix Shell](#rainbowshell---custom-unix-shell)\n  - [Table of Contents](#table-of-contents)\n  - [Features](#features)\n  - [Build](#build)\n  - [Usage](#usage)\n  - [Project Structure](#project-structure)\n  - [Examples](#examples)\n  - [Background Jobs](#background-jobs)\n\n---\n\n## Features\n\n- **Rainbow Greeting**  \n  When you launch RainbowShell, you’re greeted with a colorful gradient welcome message. Because, who don't want to meet a rainbow 🌈 ?\n\n![RainbowShell](image.png)\n\n- **Custom Command Parser**  \n  - Supports multi-stage pipelines: `cmd1 | cmd2 | cmd3`\n  - Understands logical operators: `\u0026\u0026`, `||`\n  - Sequential execution: `cmd1 ; cmd2`\n  - Subshells: `(cd / \u0026\u0026 ls -l)`\n  - Redirections: `\u003c file`, `\u003e file`, `\u003e\u003e file`\n  - Background tasks: `cmd \u0026`\n  \n- **Built-in Commands**  \n  - `cd \u003cdir\u003e`: change directory (built-in, because changing directories in a child process has no effect on the parent)\n\n- **Error Handling**  \n  - Lexer and parser produce meaningful, color-highlighted error messages (typos, missing quotes, etc).\n  - Handles partial command failures in pipelines (ex. if the last command in a pipeline fails, subsequent `\u0026\u0026` sections won’t run).\n\n- **Background Jobs**  \n  - Run commands asynchronously with `\u0026`.\n  - Automatically ignores `SIGINT` (Ctrl-C) in the background job so it won’t be interrupted.\n  - Prevents zombie processes via `waitpid`.\n\n- **Subshell \u0026 Grouping**  \n  - Parentheses `( ... )` create a new job in a subshell.  \n    Example: `(cd /; ls); pwd`\n  - You can group multiple commands, run them in the background, or combine with logical operators.\n\n- **Extensible Architecture**  \n  - Separation of **lexer**, **parser**, and **executor**.\n  - Because of it future features or built-ins can be easily added.\n\n---\n\n## Build \n\n1. **Clone** this repository:\n   ```bash\n   git clone https://github.com/estnafinema0/RainbowShell.git\n   cd RainbowShell/shell\n   ```\n2. **Compile** using `make`:\n   ```bash\n   make\n   ```\n   Now we have executable `Rainbowshell`.\n\n3. **Run** RainbowShell:\n   ```bash\n   ./Rainbowshell\n   ```\n\n---\n\n## Usage\n\nNow you are open to type any commands as in a standard Unix shell. \n```bash\nshell\u003e echo \"Hello World\"\n```\n\nUse **Ctrl-C** to send an interrupt signal to **foreground** commands. If a command is run in the background (using `\u0026`), it won’t be interrupted by **Ctrl-C** (as it should be in a usual shell!).\n\n---\n\n## Project Structure\n\n- **main.c**  \n  Entry point for RainbowShell. Handles signals (`SIGINT` and `SIGCHLD`), prints the rainbow greeting, and starts the main interactive loop.\n\n- **parser.c / parser.h**  \n  Contains the logic for parsing command lines into a structured form (`Job` and `Command` objects). Handles operators like `\u0026\u0026`, `||`, `|`, `;`, `\u0026`, as well as subshell grouping `( ... )`.\n\n- **lexer.c / lexer.h**  \n  Breaks the command line into tokens (`TOKEN_WORD`, `TOKEN_OPERATOR`, etc.). Also handles quoted strings and error checking for unclosed quotes.\n\n- **executor.c / executor.h**  \n  Executes commands by forking processes. Implements:\n  - Pipelines (`|`)\n  - Sequential commands (`;`)\n  - Conditional commands (`\u0026\u0026`, `||`)\n  - Subshells\n  - Redirections (`\u003c`, `\u003e`, `\u003e\u003e`)\n  - Background jobs (`\u0026`)\n\n- **builtins.c / builtins.h**  \n  Built-in commands such as `cd`.\n\n- **colors.c / colors.h**  \n  Provides color/gradient print utilities. The `print_rainbow_text` function produces the signature rainbow greeting.\n\n- **structures.h**  \n  Defines the primary data structures (`Command`, `Job`, `OperatorType`) used across the shell.\n\n- **makefile**  \n  Contains build rules. Simply run `make`.\n\n---\n\n## Examples\n\nHere are some commands to showcase RainbowShell’s broad functionality:\n\n1. **Subshell \u0026 Sequential**  \n   ```bash\n   (cd /; pwd); pwd\n   ```\n   - Changes directory to `/`, prints it, then returns to the parent shell and prints its current directory.\n\n2. **Conditional Execution**  \n   ```bash\n   (false \u0026\u0026 echo \"Skipped 1\") || (echo \"Fallback 1\" \u0026\u0026 echo \"Part of fallback\")\n   ```\n   - `false` fails, so `\u0026\u0026` chain is skipped; `||` triggers the fallback commands.\n\n3. **Background Task with Redirection**  \n   ```bash\n   echo \"Background task\" \u003e output.txt \u0026 cat output.txt\n   ```\n   - The `echo` runs in the background, while the shell immediately proceeds to `cat output.txt`.\n\n4. **Pipeline**  \n   ```bash\n   echo \"hello\" | grep \"hello\" \u0026\u0026 echo \"Pipeline succeeded\" || echo \"Pipeline failed\"\n   ```\n   - If `grep \"hello\"` finds the text, the `\u0026\u0026` chain continues.\n\n5. **Multiple Steps with Conditionals**  \n   ```bash\n   ls non_existent_dir \u0026\u0026 echo \"This should not print\" || echo \"Directory not found\"\n   ```\n   - Fails on the nonexistent directory, triggers the `||` fallback.\n\n6. **Process Listing and Subshell**  \n   ```bash\n   ps; ls; (cd .. ; ls; ps) \u0026\u0026 ls \u0026\u0026 ps\n   ```\n   - Shows how a subshell can change directory without affecting the parent shell.\n\n7. **Background Sleep**  \n   ```bash\n   sleep 5 \u0026 echo \"Background process test\"\n   ```\n   - `sleep` runs in the background, while RainbowShell continues to the next command.\n\n---\n\n## Background Jobs\n\nIf you type `\u0026` in the end of the command, it will launch in the background:\n- **Non-blocking background**: The shell is immediately ready for the next command.\n- **No Zombie Processes**: RainbowShell calls `waitpid` appropriately.\n- **Ignored SIGINT**: Background jobs ignor `Ctrl-C` from the main terminal.\n\n---\n\nThank you for checking out **RainbowShell**! Enjoy the rainbow!🌈 ","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Festnafinema0%2Frainbowshell","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Festnafinema0%2Frainbowshell","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Festnafinema0%2Frainbowshell/lists"}