{"id":21285345,"url":"https://github.com/izenynn/mini-shell","last_synced_at":"2025-04-14T14:12:21.320Z","repository":{"id":47796021,"uuid":"440222565","full_name":"izenynn/mini-shell","owner":"izenynn","description":"This project aims to recreate most of the bash shell.","archived":false,"fork":false,"pushed_at":"2023-04-04T14:36:39.000Z","size":456,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-28T03:11:48.820Z","etag":null,"topics":["42","42born2code","42minishell","bash","bash-like","c","linux","linux-shell","macos","macos-shell","minishell","shell"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/izenynn.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2021-12-20T15:43:21.000Z","updated_at":"2024-03-26T11:04:53.000Z","dependencies_parsed_at":"2023-01-31T05:01:15.886Z","dependency_job_id":"bd0b482b-a327-4b34-8d0b-8abde6de527d","html_url":"https://github.com/izenynn/mini-shell","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/izenynn%2Fmini-shell","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/izenynn%2Fmini-shell/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/izenynn%2Fmini-shell/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/izenynn%2Fmini-shell/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/izenynn","download_url":"https://codeload.github.com/izenynn/mini-shell/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248894938,"owners_count":21179152,"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":["42","42born2code","42minishell","bash","bash-like","c","linux","linux-shell","macos","macos-shell","minishell","shell"],"created_at":"2024-11-21T11:19:53.600Z","updated_at":"2025-04-14T14:12:21.282Z","avatar_url":"https://github.com/izenynn.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# minishell\n\n## Contents\n\n- [Info](#info)\n- [How to use](#how-to-use)\n\t- [Clone repo and submodules](#clone-repo-and-submodules)\n\t- [Linux dependencies](#linux-dependencies)\n\t- [MAC dependencies](#mac-dependencies)\n\t- [Compile and execute](#compile-and-execute)\n\t- [Install](#install)\n- [Features](#features)\n\t- [Built-in commands](#built-in-commands)\n- [Aproach](#aproach)\n- [Shell grammar](#shell-grammar)\n- [Screenshots](#screenshots)\n\n## Info\n\nThis project aims to recreate most of the bash shell.\n\n- Status: finished\n- Result: 125%\n- Observations:\n\t- It is compatible with Linux and Mac OS.\n\t- It does not use `VT100` escape characters.\n\n*developed by: [izenynn](https://github.com/izenynn) and [0xk0sta](https://github.com/0xk0sta)*\n\n## How to use\n\n### Clone repo and submodules\n\n```sh\ngit clone --recurse-submodules https://github.com/izenynn/minishell.git\n```\n\n### Linux dependencies\n\nInstall readline library:\n\n- On Debian based platforms, like Ubuntu:\n\n```sh\nsudo apt install libreadline-dev\n```\n\n- Platforms with `yum`, like SUSE:\n\n```sh\nyum install readline-devel\n```\n\n- For other platform please search for the package name on google, thx :)\n\n### MAC dependencies\n\n- Install readline library:\n\n```sh\nbrew install readline\n```\n\n### Compile and execute\n\nRun `make` (make rules: `all`, `clean`, `fclean` and `re`)\n\n```sh\ncd ./minishell \u0026\u0026 make\n```\n\nExecute the `./minishell` binary generated after running `make`\n\n```sh\n./minishell\n```\n\n### Install\n\nTo install minishell in your machine and be able to use it in any directory like any other command, run `make install` (make sure you have the correct access rights).\n\n```sh\nsudo make install\n```\n\nTo change the install directory specify the `BIN_DIR` variable on make\n\n```sh\nsudo make install -D 'BIN_DIR=/usr/local/bin'\n```\n\n## Features\n\n- Recreates most of the bash shell.\n- support for config file `.minishrc` (like bash `.bashrc`).\n- comments with `#` (NOTE: `#` must be at the start of the line).\n- Pipes `|` works like in bash.\n- Redirections `\u003c`, `\u003e`, `\u003c\u003c`, `\u003e\u003e` work like in bash.\n- `;`, `\u0026\u0026` and `||` work like in bash.\n- Parenthesis: `(` and `)` works with `\u0026\u0026`, `||` and `;` for priorities.\n- `$?` works like in bash.\n- wildcards `*` and `?` works for the current directory.\n- Handle signals: `Ctrl-C`, `Ctrl-D` and `Ctrl-\\` like in bash.\n- Enviroments variables.\n- Arrow keys.\n- History (command history).\n- Auto-complete with tab key.\n\n### Built-in commands\n\n- `echo`\n- `cd`\n- `pwd`\n- `export`\n- `unset`\n- `env`\n- `exit`\n\n## Aproach\n\nminishell is formed by 3 components:\n\n1. Lexical analyzer: parse the input line into tokens.\n\n2. Parser: parse tokens into an abstract syntax tree (ast).\n\n3. Executor: execute the commands\n\nTo see how it works, go to `src/main/handle_line.c`, uncomment the functions `print_ast` and `print_tokens`, in line 18 and 78, add the following lines to the `handle_line` function and run `make` again:\n\n```diff\n void\thandle_line(char *line, t_bool is_alloc)\n {\n \tt_lexer\tlex;\n \tt_ast\t*ast;\n \tint\t\tret;\n\n \tast = NULL;\n \tif (check_line(line, is_alloc) == 1)\n \t\treturn ;\n \tret = lexer_build(line, ft_strlen(line), \u0026lex);\n \tif (ret \u003c= 0)\n \t{\n \t\tif (ret == 0 \u0026\u0026 g_sh.tokdel == FALSE)\n \t\t\twrite(STDERR_FILENO, \"error: syntax error\\n\", 20);\n \t\tfree_line(line, is_alloc);\n \t\tlexer_del(\u0026lex);\n \t\treturn ;\n \t}\n \tfree_line(line, is_alloc);\n+\tprint_tokens(\u0026lex);\n \tif (lex.n_toks == 0 || parse(\u0026lex, \u0026ast))\n \t{\n \t\tfree_all(\u0026lex, ast);\n \t\treturn ;\n \t}\n+\tprint_ast(ast, 0); printf(\"------------------------------------\\n\");\n \tif (exec_heredoc(ast) == 0)\n \t\texec_ast(ast);\n \tfree_all(\u0026lex, ast);\n }\n```\n\nExample:\n\n```txt\nminishell$ \"invalid command\" || (echo hello \u0026\u0026 echo world!)\n------------------------------------\nTOKENS:\nn_tok: 10\ntype: -1, data: invalid command\ntype: 124, data: |\ntype: 124, data: |\ntype: 40, data: (\ntype: -1, data: echo\ntype: -1, data: hello\ntype: 38, data: \u0026\ntype: 38, data: \u0026\ntype: -1, data: echo\ntype: -1, data: world!\ntype: 41, data: )\ntype: 0, data:\n------------------------------------\nAST:\n\n                              type: arg, data: world!\n\n                    type: cmd, data: echo\n\n          type: \u0026\u0026\n\n                              type: arg, data: hello\n\n                    type: cmd, data: echo\n\ntype: ||\n\n          type: cmd, data: invalid command\n------------------------------------\ninvalid command: command not found\nhello\nworld!\nminishell$\n```\n\n## Shell grammar\n\n```txt\nGrammar\n\n\u003ccommand line\u003e : \u003cand or\u003e ';' \u003ccommand line\u003e\n               | \u003cand or\u003e ';'\n               | \u003cand or\u003e\n               ;\n\n\u003cand or\u003e       : \u003cjob\u003e '\u0026\u0026' \u003cand or\u003e\n               | \u003cjob\u003e '||' \u003cand or\u003e\n               | \u003cjob\u003e\n               | '(' \u003ccommand line\u003e ')' '\u0026\u0026' \u003cand or\u003e\n               | '(' \u003ccommand line\u003e ')' '||' \u003cand or\u003e\n               | '(' \u003ccommand line\u003e ')'\n               ;\n\n\u003cjob\u003e          : '(' \u003ccommand\u003e ')' '|' \u003cjob\u003e\n               |     \u003ccommand\u003e     '|' \u003cjob\u003e\n               | '(' \u003ccommand\u003e ')'\n               |     \u003ccommand\u003e\n               ;\n\n\u003ccommand\u003e      : \u003ctoken list\u003e\n               ;\n\n\u003ctoken list\u003e   : [name]  \u003ctoken list\u003e\n               | [token] \u003ctoken list\u003e\n               | [redir] \u003ctoken list\u003e\n               | (null)\n               ;\n\n\u003credir\u003e        : \u003credir in\u003e\n               | \u003credir out\u003e\n               ;\n\n\u003credir in\u003e     : '\u003c\u003c' [file]\n               | '\u003c'  [file]\n               ;\n\n\u003credir out\u003e    : '\u003e\u003e' [file]\n               | '\u003e'  [file]\n               ;\n```\n\n## Screenshots\n\n![screenshot 00](https://github.com/izenynn/minishell/blob/main/screenshots/00.png)\n\n![screenshot 01](https://github.com/izenynn/minishell/blob/main/screenshots/01.png)\n\n![screenshot 02](https://github.com/izenynn/minishell/blob/main/screenshots/02.png)\n\n![screenshot 03](https://github.com/izenynn/minishell/blob/main/screenshots/03.png)\n\n![screenshot 04](https://github.com/izenynn/minishell/blob/main/screenshots/04.png)\n\n![screenshot 05](https://github.com/izenynn/minishell/blob/main/screenshots/05.png)\n\n![screenshot 06](https://github.com/izenynn/minishell/blob/main/screenshots/06.png)\n\n![screenshot 07](https://github.com/izenynn/minishell/blob/main/screenshots/07.png)\n\n![screenshot 08](https://github.com/izenynn/minishell/blob/main/screenshots/08.png)\n\n##\n\n[![forthebadge](https://forthebadge.com/images/badges/made-with-c.svg)](https://forthebadge.com)\n[![forthebadge](https://forthebadge.com/images/badges/you-didnt-ask-for-this.svg)](https://forthebadge.com)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fizenynn%2Fmini-shell","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fizenynn%2Fmini-shell","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fizenynn%2Fmini-shell/lists"}