{"id":18337780,"url":"https://github.com/pin3dev/42_minishell","last_synced_at":"2025-04-09T20:18:42.449Z","repository":{"id":203317694,"uuid":"695261532","full_name":"pin3dev/42_Minishell","owner":"pin3dev","description":"A simple Unix shell written in C, replicating the basic functionalities of a shell, including command execution, pipes, and redirections. Designed to deepen understanding of system calls and process management in Unix-like systems.","archived":false,"fork":false,"pushed_at":"2024-08-08T14:31:00.000Z","size":1733,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-09T20:18:38.125Z","etag":null,"topics":["42born2code","42cursus","42projects","42school","minishell","minishell-42","minishell42"],"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/pin3dev.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":"2023-09-22T17:59:35.000Z","updated_at":"2024-08-28T13:29:35.000Z","dependencies_parsed_at":null,"dependency_job_id":"5e224868-1c16-41da-b205-af7203bb509f","html_url":"https://github.com/pin3dev/42_Minishell","commit_stats":null,"previous_names":["pin3dev/42_minishell"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pin3dev%2F42_Minishell","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pin3dev%2F42_Minishell/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pin3dev%2F42_Minishell/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pin3dev%2F42_Minishell/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pin3dev","download_url":"https://codeload.github.com/pin3dev/42_Minishell/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248103908,"owners_count":21048246,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["42born2code","42cursus","42projects","42school","minishell","minishell-42","minishell42"],"created_at":"2024-11-05T20:12:15.618Z","updated_at":"2025-04-09T20:18:42.421Z","avatar_url":"https://github.com/pin3dev.png","language":"C","readme":"# Minishell `100/100`\nMinishell - As beautiful as a shell 🐚\n\n\u003eIn this repository, you'll find a detailed description of what this project entails, instructions on how to test it, and soon, a comprehensive theoretical breakdown of its construction. Our aim is to provide a clear and thorough overview, making it easy for you to navigate, explore, or contribute to this project. Scroll down for more in-depth details and relevant information.\n\n## Table of Contents\n- [Project Overview](#overview)\n- [Mandatory Features](#mandatory-features)\n- [Project Compilation and Execution](#compilation-and-execution)\n- [Tests -  Usage Examples (toggle-able)](#usage-examples)\n- [Theoretical Explanation (toggle-able)](#theoretical-explanation)\n- [Copyright](#contributors)\n\n---\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://github.com/pin3dev/42_Cursus/blob/50e11197fa2b1e646ae477492626faa09104da83/assets/Minishell/Rdm/minishell_redirs_pipes.gif\" alt=\"gif_minishell_test\" style=\"display: block; margin: 0 auto; width: 100%;\"\u003e\n\u003c/p\u003e\n\n---\n\n## Overview\n\nThis project is a simplified implementation of a Unix shell, adhering to the `minishell` project curriculum of 42 school. This was carried out following the rules described in the [`subject`](https://github.com/pin3dev/42_Cursus/blob/50e11197fa2b1e646ae477492626faa09104da83/assets/Minishell/Rdm/minishell_en.subject.pdf) version 7 released 2023.\n\n## Mandatory Features\n\n1.  Display command prompt.\n2.  Maintain command history.\n3.  Locate and launch executables using PATH, relative, or absolute paths.\n4.  Restrict to one global variable for signal indication.\n5.  Ignore unneeded special characters (e.g., `\\` and `;`).\n6.  Proper handling of quotes (`'` and `\"`).\n7.  Redirections: `\u003c`, `\u003e`, `\u003c\u003c`, `\u003e\u003e`.\n8.  Piping using `|`.\n9.  Manage environment variables (`$` and `$?`).\n10.  Handle signals: `CTRL-C`, `CTRL-D`, `CTRL-\\`.\n11.  Built-in commands: `echo`, `cd`, `pwd`, `export`, `unset`, `env`, `exit`.\n\n## Compilation and Execution\n\n```bash\nmake\n./minishell\n```\n\n---\n\n\u003cdetails\u003e\u003csummary\u003e\u003ch2 id=\"Usage Examples\"\u003eUsage Examples\u003c/h2\u003e\u003c/summary\u003e\n\nThe tests below were thought up by my friend `@waltergcc`, for more examples you can visit his [repository here](https://github.com/waltergcc/42-minishell#tests)\n\n## Table of Tests\n- [General](#general)\n- [Quotes](#quote-handling)\n- [Builtins](#builtins)\n- [Expanding $?](#expanding-exit-status-variables-by-)\n- [Expanding $](#expanding-environment-variables-by-)\n- [Signals](#signal-control-by-ctrlc-ctrld-ctrl)\n- [Pipes](#pipes)\n- [Redirs and Heredocs](#redirs-and-heredoc)\n\n### General\n```bash\ncliva_minixHell\u003e date\n#[...command output...]\ncliva_minixHell\u003e who\n#[...command output...]\ncliva_minixHell\u003e touch 1 2 3\ncliva_minixHell\u003e ls\n#[...command output + files 1 2 3 created...]\ncliva_minixHell\u003e rm 1 2 3\ncliva_minixHell\u003e ls\n#[...command output without removed files 1 2 3...]\ncliva_minixHell\u003e /bin/ls\n#[...command output...]\n\n#I encourage you to test with more commands, you can use your creativity\n```\n\n### Quote Handling\n```bash\ncliva_minixHell\u003e \"/bin/ls\"\n#[...command output...]\ncliva_minixHell\u003e \"ls\"\n#[...command output...]\ncliva_minixHell\u003e \"ls -l\"\n#[...error output...]\ncliva_minixHell\u003e \"cat\" existing_files\n#[...content of existing file output...]\ncliva_minixHell\u003e \"cat existing_files\"\n#[...error output...]\n\n#I encourage you to try another type and quantity of quotation marks, mixing double and single quotation marks, you can use your creativity\n```\n\n### Builtins\n\n###### ECHO:\n```bash\ncliva_minixHell\u003e echo This is a test\n#[This is a test]\ncliva_minixHell\u003e echo -n Hello World\n#[Hello Worldcliva_minixHell\u003e]\ncliva_minixHell\u003e echo -n -n -n -n -n Hello World\n#[Hello Worldcliva_minixHell\u003e]\ncliva_minixHell\u003e echo -nnnnnnnnn Hello World\n#[Hello Worldcliva_minixHell\u003e]\ncliva_minixHell\u003e echo \"Hello      with       spaces\"\n#[\"Hello with spaces\"]\ncliva_minixHell\u003e echo \"test with %specials *chars\"\n#[test with %specials *chars]\ncliva_minixHell\u003e echo \"cat lol.c cat \u003e Iol.c\"\n#[cat lol.c cat \u003e Iol.c]\ncliva_minixHell\u003e echo 'Hello      with       spaces'\n#[\"Hello with spaces\"]\ncliva_minixHell\u003e echo 'test with %specials *chars'\n#[test with %specials *chars]\ncliva_minixHell\u003e echo 'cat lol.c cat \u003e Iol.c'\n#[cat lol.c cat \u003e Iol.c]\ncliva_minixHell\u003e echo '$HOME \u003e home.txt'\n#[$HOME \u003e home.txt]\n\n#I encourage you to test the status with other commands such as expr for example, you can use your creativity\n```\n\n###### CD, PWD \u0026 ENV\n```bash\ncliva_minixHell\u003e env\n#[...current list of environment variables with their values output...]\ncliva_minixHell\u003e pwd\n#[...path of your current directory output...] \ncliva_minixHell\u003e cd .\n#[...stay on your current directory...]\ncliva_minixHell\u003e cd ..\n#[...change to the parent directory of the current directory...]\ncliva_minixHell\u003e cd /path/to/a/directory\n#[...change to the directory provided...]\ncliva_minixHell\u003e cd \n#[...change to the HOME directory...]\n```\n\n###### EXPORT:\n```bash\ncliva_minixHell\u003e export NEW_VAR\ncliva_minixHell\u003e export\n#[...current list of environment variables with their values in alphabetical order, including the NEW_VAR...]\ncliva_minixHell\u003e env\n#[...current list of environment variables with their values in common order, without the NEW_VAR...]\ncliva_minixHell\u003e export NEW_VAR=42\ncliva_minixHell\u003e export\n#[...current list of environment variables with their values in alphabetical order, including the NEW_VAR and their new value...]\ncliva_minixHell\u003e env\n#[...current list of environment variables with their values in common order, with the NEW_VAR and their value...]\ncliva_minixHell\u003e export NEW_VAR=\"A little change\"\ncliva_minixHell\u003e export\n#[...current list of environment variables with their values in alphabetical order, including the NEW_VAR and their new value...]\ncliva_minixHell\u003e export NEW_VAR=$USER\ncliva_minixHell\u003e export\n#[...current list of environment variables with their values in alphabetical order, including the NEW_VAR and their new value (YOUR_USERNAME)...]\ncliva_minixHell\u003e export 123=VALUE\n#[...error output...]\ncliva_minixHell\u003e export _123=VALUE\ncliva_minixHell\u003e export\n#[...current list of environment variables with their values in alphabetical order, including the _123 and their value...]\n```\n\n###### UNSET:\n```bash\ncliva_minixHell\u003e unset NEW_VAR _123\ncliva_minixHell\u003e export\n#[...current list of environment variables with their values in alphabetical order, without NEW_VAR and _123...]\ncliva_minixHell\u003e env\n#[...current list of environment variables with their values in common order, without NEW_VAR and _123...]\ncliva_minixHell\u003e unset HOME\ncliva_minixHell\u003e cd\n#[...error output...]\ncliva_minixHell\u003e unset PATH\ncliva_minixHell\u003e #HERE TRY ANY COMMAND\n#[...error output...]\n```\n\n###### EXIT\n```bash\ncliva_minixHell\u003e exit\n#[exit]\n```\n\n### Expanding Exit Status Variables By `$?`\n```bash\ncliva_minixHell\u003e ./minishell\ncliva_minixHell\u003e exit 1\n#[exit]\ncliva_minixHell\u003e echo $?\n#[1]\ncliva_minixHell\u003e ./minishell\ncliva_minixHell\u003e exit 42\n#[exit]\ncliva_minixHell\u003e echo $?\n#[42]\ncliva_minixHell\u003e ./minishell\ncliva_minixHell\u003e exit -42\n#[exit]\ncliva_minixHell\u003e echo $?\n#[214]\ncliva_minixHell\u003e ./minishell\ncliva_minixHell\u003e exit 42 10\n#[exit]\n#[...error output...]\ncliva_minixHell\u003e echo $?\n#[1]\ncliva_minixHell\u003e ./minishell\ncliva_minixHell\u003e exit 42blabla\n#[...error output...]\n\n#\n```\n\n### Expanding Environment Variables By `$`\n```bash\ncliva_minixHell\u003e echo $HOME\n#[...your HOME path...]\ncliva_minixHell\u003e echo \"$HOME\"\n#[...your HOME path...]\ncliva_minixHell\u003e echo '$HOME'\n#[$HOME]\ncliva_minixHell\u003e echo $HOME.test\n#[...your HOME path + .test...]\ncliva_minixHell\u003e echo $HOME/test\n#[...your HOME path + /test...]\ncliva_minixHell\u003e echo $HOME.test/$USER\n#[...your HOME path + /test + / +  your USER name...]\n```\n\n### Signal Control by `CTRL+C`, `CTRL+D`, `CTRL+\\`\n###### EMPTY PROMPT\n\n```bash\ncliva_minixHell\u003e #HOLD CTRL+C\n#[^C]\ncliva_minixHell\u003e echo $?\n#[130]\ncliva_minixHell\u003e #HOLD CTRL+\\\n#[...nothing happens...]\ncliva_minixHell\u003e #HOLD CTRL+D\n#[exit]\nbash\u003e echo $?\n#[0]\n```\n\n###### FULL PROMPT\n\n```bash\ncliva_minixHell\u003e digit anything here #HOLD CTRL+C\n#[^C]\ncliva_minixHell\u003e echo $?\n#[130]\ncliva_minixHell\u003e digit anything here #HOLD CTRL+\\\n#[...nothing happens...]\ncliva_minixHell\u003e digit anything here #HOLD CTRL+D\n#[...nothing happens...]\n```\n\n###### INTERACTIVE MODE\n\n```bash\ncliva_minixHell\u003e cat\n#[...interactive mode...]\ncliva_minixHell\u003e #HOLD CTRL+C\n#[^C]\ncliva_minixHell\u003e echo $?\n#[130]\ncliva_minixHell\u003e cat\n#[...interactive mode...]\ncliva_minixHell\u003e #HOLD CTRL+\\\n#[\\Quit (core dumped)]\ncliva_minixHell\u003e echo $?\n#[131]\ncliva_minixHell\u003e cat\n#[...interactive mode...]\ncliva_minixHell\u003e #HOLD CTRL+D\n#[exit]\nbash\u003e echo $?\n#[0]\n```\n\n### Pipes\n```bash\ncliva_minixHell\u003e cat Makefile | grep NAME | wc -l\n#[...how many lines are in the Makefile with NAME...]\ncliva_minixHell\u003e ps aux | sort -rk 4 | head\n#[...List the processes that consume the most memory...]\ncliva_minixHell\u003e ls -l | grep \"^-\" | wc -l\n#[...Count the number of files in a directory...]\n```\n\n### Redirs and Heredoc\n```bash\ncliva_minixHell\u003e ls -l \u003e test\n#[...create test file with the ls output inside...]\ncliva_minixHell\u003e cat Makefile \u003e\u003e test\n#[...add Makefile content on file test...]\ncliva_minixHell\u003e wc -l \u003c test\n#[...count the number of lines of file test..]\ncliva_minixHell\u003e cat \u003c\u003c EOF\nHI GUYS\nEOF\n#[HI GUYS]\ncliva_minixHell\u003e cat \u003c\u003c EOF | wc -l\nHI GUYS\nEOF\n#[1]\ncliva_minixHell\u003e cat \u003c\u003c EOF\nHI GUYS\nHERE IS \"$USER\"\nEOF\n#[HI GUYS \n# HERE IS \"YOUR_USER\"]\ncliva_minixHell\u003e \u003c test cat \u003e test2\n#[...create test2 file with thetest file content...]\ncliva_minixHell\u003e wc -l \u003c /etc/passwd \u003e file1 \u003e file2 \u003e file3 \u003e file4\n#[...create file1, 2 and 3 empty and file4 with the  countn lines of passwd file content...]\n```\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003e\u003ch2 id=\"Theoretical Explanation\"\u003eTheoretical Explanation\u003c/h2\u003e\u003c/summary\u003e\n\n  \u003esoon\n\n\u003c/details\u003e\n\n## Contributors\n\n\u003eI would like to extend my deepest gratitude to the `@clima-fr` for the remarkable partnership. Together, we navigated 42 intense days, filled with challenges and learning experiences. Your commitment and dedication were pivotal in bringing this project to fruition. Thank you for every shared moment and all the hard work throughout this journey.\n\n* Ívany Pinheiro aka [`@pin3dev`](https://github.com/pin3dev)\n* Clara Franco aka [`@clima-fr`](https://github.com/clima-fr)\n\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpin3dev%2F42_minishell","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpin3dev%2F42_minishell","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpin3dev%2F42_minishell/lists"}