{"id":26167520,"url":"https://github.com/izzytoot/minishell","last_synced_at":"2026-04-24T13:32:36.494Z","repository":{"id":281188369,"uuid":"938860937","full_name":"izzytoot/minishell","owner":"izzytoot","description":"This project is about creating a simple shell.","archived":false,"fork":false,"pushed_at":"2025-07-03T12:00:25.000Z","size":10014,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-26T02:29:38.339Z","etag":null,"topics":["bash","fd","processes"],"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/izzytoot.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-02-25T16:07:25.000Z","updated_at":"2025-11-06T21:56:22.000Z","dependencies_parsed_at":"2025-03-29T17:26:52.216Z","dependency_job_id":"80faf506-b3bd-4695-abc7-006001a7c736","html_url":"https://github.com/izzytoot/minishell","commit_stats":null,"previous_names":["izzytoot/minishell"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/izzytoot/minishell","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/izzytoot%2Fminishell","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/izzytoot%2Fminishell/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/izzytoot%2Fminishell/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/izzytoot%2Fminishell/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/izzytoot","download_url":"https://codeload.github.com/izzytoot/minishell/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/izzytoot%2Fminishell/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32225744,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-24T13:21:15.438Z","status":"ssl_error","status_checked_at":"2026-04-24T13:21:15.005Z","response_time":64,"last_error":"SSL_read: 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":["bash","fd","processes"],"created_at":"2025-03-11T17:38:28.144Z","updated_at":"2026-04-24T13:32:36.487Z","avatar_url":"https://github.com/izzytoot.png","language":"C","readme":"# 🐚 MINISHELL \n\n## ℹ️ About the project\nThis project was done in partnership with [**Daniela Padilha**](https://github.com/Daniela-Padilha).\n\nIt's a polished, mini‑version of a Unix shell written in pure C. This isn’t just an exercise - it’s about building a real, working Command-Line Interface interpreter that plays nicely with pipes, redirections, heredocs, expansions, signals, and error handling.\n\n## 💪 What It Does\n1. Reads user input (with readline support for line editing and history);\n2. Validates syntax (no unclosed quotes, misplaced operators, etc.);\n3. Tokenizes the input and attributed different categories: pipes, redirections, commands (builtins or environment), arguments;\n4. Builds an AST (Binary Tree) reflecting pipes, redirections, and commands;\n5. Executes it, handling builtins, environment lookup, subprocesses;\n\nThe program manages heredocs, multi‑stage redirections, pipes, signals, and exit statuses.\n\n⚠️ We took each piece step by step, ending with a code that works and handles everything gracefully.\n\n## 🧠 Implementation Phases\nHere's how it all comes together:\n\n#### \u003cins\u003ea. Syntax Check\u003c/ins\u003e\n- It scans the raw input for basic syntax sanity;\n- It detects unclosed quotes, misplaced pipes/redirections, usage of unsuppported operators (\u0026\u0026 and ||);\n- It refuses to parse broken commands early, printing errors like bash would;\n\n#### \u003cins\u003eb. Tokenization \u0026 Sub‑tokenization\u003c/ins\u003e\n- It keeps track of quoting modes to prevent unintended word-splitting;\n- It splits input into tokens: words, pipes, redirections;\n- It further splits word tokens into filenames, type of command (builtin or environment) or arguments;\n- It checks for repeated command words and empty quote situations;\n\n#### \u003cins\u003ec. Binary Tree (AST) Building\u003c/ins\u003e\n- It parses the token stream into a binary tree:\n- Pipes (|) create left and right branches;\n- Redirections link to command nodes and filename nodes;\n- Command nodes will be the last node of the tree.\n- This structure reflects evaluation order and establishes an execution flow.\n\n🌳 **BINARY TREE EXAMPLE** \n\n\u003cins\u003eInput line:\u003c/ins\u003e cat file.txt | grep hello \u003e out.txt\n\n              PIPE\n              \"|\"\n             /    \\\n         CMD       REDIR_OUT\n        \"cat\"         \"\u003e\"\n         ARG         /   \\\n       file.txt    CMD   FILENAME\n                 \"grep\"  \"out.txt\"\n                  ARG\n                \"hello\"\n\nExecutes left branch first (cat file.txt) and writes into pipe, and right branch after (grep hello \u003e out.txt), reading from pipe.\n\n#### \u003cins\u003ed. Tree Execution\u003c/ins\u003e\nTraverses and executes the AST:\n\n##### d.1 Expansions\n\n- It handles \"$VAR\", \"$?\", \"$0\" and \"$EMPTY\" expansions;\n- It performs word-splitting or joining after expansions unless inside single quotes;\n- It replaces the node-argument array;\n\n##### d.2 Heredoc Execution\n\n- It detects how many heredocs are there in the input line;\n- It performs the existant heredocs by:\n  - detecting the EOF,\n  - creating a temporary file,\n  - opening a heredoc buffer in a child process,\n  - expanding variables inside heredoc if EOF not quoted.\n\n##### d.3 Pipe Execution\n\n- It chains tree nodes through pipes;\n- It uses fork(), pipe(), and dup2() to connect child processes;\n\n##### d.4 Redirections Execution\n\n- It applies \u003c, \u003e, and \u003e\u003e to redirect stdin/stdout;\n- It opens files with correct flags and uses dup2() to hook them;\n- It handles FD opening, duplicating and closing;\n- It performs the command linked to the redirect token te correct stdin/stdout;\n\n##### d.5 Command Execution\n\n-  Builtin Commands\n  - cd, echo, pwd, export, unset, env, exit;\n  - Executed in parent process;\n  - It outputs errors and updates exit status without forking.\n\n- Environment Commands\n  - Launch external executables using execve()\n  - Executed in child process, it searches PATH, handles ENOENT and prints meaningful error messages like bash.\n\n#### \u003cins\u003ee. Transversal Mechanics\u003c/ins\u003e\nThese mechanics touch every part of the shell:\n\n\u003cins\u003eSignal Handling\u003c/ins\u003e\n\n- SIGINT (Ctrl+C): interrupts input or current command, then resets prompt;\n- SIGQUIT (Ctrl+\\): ignored, same behavior as bash;\n- Interactive handling during heredoc, builtins, execution phases.\n\n\u003cins\u003eExit Code Handling\u003c/ins\u003e\n\n- Every command sets the correct exit code;\n- Exit codes can be checked by expanding $?;\n- Child processes inherit parent’s signal-derived or exec-derived exit status;\n\n## 🔥 Build, run and test\n\n```\ngit clone \u003chttps://github.com/izzytoot/minishell.git\u003e\ncd minishell\nmake\n./minishell\n```\n\nFeel free to test our Minishell. Here is our own list of tests which we compiled troughout this loooooong journey. Have fun!\n\n## 😱 **[OUR LIST OF 282 TESTS](https://www.notion.so/meeru/1d02544e44e2807d9013fd3eefbfebf4?v=1d02544e44e28087a970000c7fb78979)** 😱\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fizzytoot%2Fminishell","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fizzytoot%2Fminishell","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fizzytoot%2Fminishell/lists"}