{"id":19390182,"url":"https://github.com/thomas-chqt/minishell","last_synced_at":"2026-05-18T07:05:37.340Z","repository":{"id":190108130,"uuid":"669860686","full_name":"Thomas-Chqt/minishell","owner":"Thomas-Chqt","description":"bash-like shell","archived":false,"fork":false,"pushed_at":"2024-08-31T05:33:13.000Z","size":4472,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-07T09:37:36.452Z","etag":null,"topics":["42","shell","syscalls","unix"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Thomas-Chqt.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}},"created_at":"2023-07-23T17:01:57.000Z","updated_at":"2024-08-31T05:33:16.000Z","dependencies_parsed_at":null,"dependency_job_id":"e1363716-8811-402c-a1f1-81a256fe8fdd","html_url":"https://github.com/Thomas-Chqt/minishell","commit_stats":null,"previous_names":["thomas-chqt/minishell"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Thomas-Chqt%2Fminishell","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Thomas-Chqt%2Fminishell/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Thomas-Chqt%2Fminishell/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Thomas-Chqt%2Fminishell/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Thomas-Chqt","download_url":"https://codeload.github.com/Thomas-Chqt/minishell/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240549430,"owners_count":19819137,"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","shell","syscalls","unix"],"created_at":"2024-11-10T10:19:18.738Z","updated_at":"2026-05-18T07:05:37.243Z","avatar_url":"https://github.com/Thomas-Chqt.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"minishell\n=========\n\nminishell is a bash-like shell that provides a good subset of bash features. This is the first group project at 42.\n\nFor more information about the subject, please refer to [Subject.pdf](Subject.pdf).\n\nFeatures\n--------\n\nminishell is able to:\n\n- Run a program using its absolute path or using the `PATH` environment variable.\n- Redirect the input and output of a program using `\u003c`, `\u003e`, or `\u003e\u003e`.\n- Use heredoc as input when using `\u003c\u003c`.\n- Handle double and single quotes properly to escape special characters like bash or zsh.\n- Handle pipes `|` to redirect the standard output of a program to the standard input of the next program.\n- Handle environment variables, user-defined ones, or the built-in `$?` to get the return value of the last command.\n- Handle `ctrl-C`, `ctrl-D`, and `ctrl-\\` properly when no program is running or forward all the signals to the running program.\n- And more.\n\nThe following commands are built into the shell and may not support all the options and arguments. Refer to [Subject.pdf](Subject.pdf) for more information:\n\n- echo\n- cd\n- pwd\n- export\n- unset\n- env\n- exit\n\nCommand history and autocompletions are also supported, but this is done automatically by readline.\n\nRequirements\n------------\n\nminishell can only be built on macOS and Linux with either clang or gcc.\n\nThe readline library is required to build. The version of readline installed on macOS is not enough; it must be installed with Homebrew (`brew install readline`) or any other way.\n\nBuild\n-----\n\nThe project can be built using CMake.\n\n```sh\nmkdir build\ncmake -S . -B build\ncmake --build build\n```\n\nFor CMake to find the readline library, it must either be in a standard system library directory or the directory must be included in the `LD_LIBRARY_PATH` environment variable. Alternatively, you can pass the path to the library or the directory containing it to CMake during configuration using `MSH_READLINE_DIR` or `MSH_READLINE_PATH`.\n\nExample:\n\n```sh\nmkdir build\ncmake -S . -B build -DMSH_READLINE_DIR=/usr/local/opt/readline/lib\ncmake --build build\n```\n\nUsage\n-----\n\nAfter building, minishell can be run directly and used like any shell.\n\n```sh\n./build/minishell\n```\n\nExamples\n--------\n\n![exemple1](exemple1.png)\n![exemple2](exemple2.png)\n\nLibraries\n---------\n\nminishell only uses readline to print a prompt and get the command as a string. readline also provides autocompletion with tab and command history using up and down arrows.\nOnly a limited set of functions were allowed, including required ones like `pipe` and `fork`, but more advanced functions like `strlcpy` or `strlcat` were not permitted. This is why we utilized the libft library, a collection of utility functions developed during the first project at 42 and continuously improved thereafter.\n\nLearning\n--------\n\nminishell was a very interesting project to work on. It allowed me to gain a deep understanding of how a shell works and how interprocess communication is done in a UNIX environment.  \nminishell was also a great opportunity to improve my git and GitHub skills as it was a group project. We heavily used GitHub to synchronize our work and manage any bugs we encountered through issues and pull requests.  \nSince I focused more on the lexer, parser, and expander parts, that's where I faced the most difficulties.  \nBecause it is required to implement a lot of functionalities, minishell is a project that could easily go wrong during evaluation. The subject is very vague on the requirements, so everything that is not mentioned must be exactly like bash. This was the most challenging aspect for me. For example, executing the following command:\n\n```sh\n✔︎ minishell \u003e ON='o -n'\n✔︎ minishell \u003e ech$ON hello\n```\n\nshould be interpreted as:\n\n```sh\n✔︎ minishell \u003e echo -n hello\n```\n\nwhere a naive way of expanding environment variables would interpret it as:\n\n```sh\n✔︎ minishell \u003e 'echo -n' hello\n```\n\nThis becomes even more complicated considering that bash throws parsing errors before expansion errors. So, executing the command:\n\n```sh\n✔︎ minishell \u003e | echo ${.}\n```\n\nshould throw a parsing error and not a bad substitution error.  \nTo handle these cases, I ended up doing 2 passes on the lexer, one on the command string and one on the expanded token after substituting the variables. So, the whole workflow looks something like this:\n\n```txt\nlexer -\u003e parser -\u003e expander -\u003e lexer -\u003e AST -\u003e execution\n```\n\nIn conclusion, minishell was one of my favorite projects at 42 because of the amount of knowledge I gained about shells, git, GitHub, and collaborative work in software development.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthomas-chqt%2Fminishell","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthomas-chqt%2Fminishell","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthomas-chqt%2Fminishell/lists"}