{"id":18879462,"url":"https://github.com/tjensen42/42-minishell","last_synced_at":"2025-04-14T19:22:48.634Z","repository":{"id":37759082,"uuid":"423930948","full_name":"tjensen42/42-minishell","owner":"tjensen42","description":"This project is about creating a simple shell. Like an own little bash. We learned a lot about processes, file descriptors and many other things about the shell itself.","archived":false,"fork":false,"pushed_at":"2022-11-20T17:49:02.000Z","size":590,"stargazers_count":24,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-28T07:51:09.518Z","etag":null,"topics":["42","42project","bash","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/tjensen42.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}},"created_at":"2021-11-02T17:06:25.000Z","updated_at":"2025-02-15T16:18:16.000Z","dependencies_parsed_at":"2022-08-19T02:12:18.792Z","dependency_job_id":null,"html_url":"https://github.com/tjensen42/42-minishell","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/tjensen42%2F42-minishell","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tjensen42%2F42-minishell/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tjensen42%2F42-minishell/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tjensen42%2F42-minishell/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tjensen42","download_url":"https://codeload.github.com/tjensen42/42-minishell/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248943415,"owners_count":21186958,"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","42project","bash","minishell","shell"],"created_at":"2024-11-08T06:36:33.578Z","updated_at":"2025-04-14T19:22:48.607Z","avatar_url":"https://github.com/tjensen42.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 42-minishell\n\nThe objective of this project is to create a simple shell, like an own little bash.\u003cbr\u003e\nIt is the first group project in the 42 core curriculum. \u003cb\u003e([tjensen42](https://github.com/tjensen42) \u0026\u0026 [hepple42](https://github.com/hepple42))\u003c/b\u003e\n\n## Project specifications\n\nFor the project we were allowed to use GNU's readline library which handles the terminal interaction (history \u0026 input reading).\nFor everything else the subject allows only to use a few low-level functions and a few POSIX system calls.\n\n\u003cb\u003eAllowed functions:\u003c/b\u003e\n```readline, rl_clear_history, rl_on_new_line,rl_replace_line, rl_redisplay, add_history, printf, malloc, free, write, access, open, read,close, fork, wait, waitpid, wait3, wait4, signal, sigaction, sigemptyset, sigaddset, kill, exit, getcwd, chdir, stat, lstat, fstat, unlink, execve, dup, dup2, pipe, opendir, readdir, closedir, strerror, perror, isatty, ttyname, ttyslot, ioctl, getenv, tcsetattr, tcgetattr, tgetent, tgetflag, tgetnum, tgetstr, tgoto, tputs```\n\n## Features\n\n### Basics:\n- History of previous entered commands\n- Search and launch the right executable (based on the PATH variable, using a relative or an absolute path)\n- Environment variables ($ followed by a sequence of characters) expand to their values\n- Wildcards * in the current working directory\n- ctrl-C, ctrl-D and ctrl-\\ behave like in bash\n- ```’``` (single quotes - prevent from interpreting meta-characters in quoted sequence)\n- ```\"``` (double quotes - prevent from interpreting meta-characters in quoted sequence except for $)\n- ```$?``` expands to the last exit status\n- ```|``` connect cmds or groups with pipes; output of a cmd is connected to the input of the next cmd via a pipe\n- ```\u0026\u0026``` and ```||``` with parenthesis for priorities\n\n### Builtins:\n- ```echo``` with option -n\n- ```cd``` (relative or absolute path, ```-``` for OLDPWD, without arg for HOME)\n- ```pwd``` without options\n- ```export``` without options\n- ```unset``` without options\n- ```env``` without options\n- ```exit [exit_status]``` without options\n\n### Redirections:\n\n```[n]``` (optional) specifies the file descriptor, if not specified it is stdout/stdin\n\n- ```[n]\u003c file``` Redirecting Input\n- ```[n]\u003c\u003c limiter``` Here Documents\n- ```[n]\u003e file``` Redirecting Output\n- ```[n]\u003e\u003e file``` Appending Redirected Output\n\n## How to use\n\nThe current version of minishell is developed and tested on macOS, but it should work on all UNIX/LINUX based systems as well.\n\n\u003cb\u003eRequirements:\u003c/b\u003e\n- GCC / CLANG Compiler\n- GNU Make\n- GNU Readline library\n\n```\ngit clone https://github.com/tjensen42/42-minishell.git minishell\n```\n```\ncd minishell \u0026\u0026 make release\n```\n```\n./minishell\n```\n\n## Dependencies\n### Install readline with [brew](https://brew.sh/)\n```\nbrew install readline\n```\n\n```\nbrew link --force readline\n```\n\nAdd the path to the lib\n\nReplace ~/.zshrc with ~/.bashrc if you use bash instead of zsh\n```\necho 'export C_INCLUDE_PATH=\"/usr/local/opt/readline/include:$C_INCLUDE_PATH\"' \u003e\u003e ~/.zshrc\n```\n```\necho 'export LIBRARY_PATH=\"/usr/local/opt/readline/lib:$LIBRARY_PATH\"' \u003e\u003e ~/.zshrc\n```\n```\nsource ~/.zshrc\n```\n\n### Install readline on 42 Macs\n\nInstall Brew, \u003cb\u003eonly if it is not already installed:\u003c/b\u003e\n\n```\nrm -rf $HOME/.brew \u0026\u0026 git clone --depth=1 https://github.com/Homebrew/brew $HOME/.brew \u0026\u0026 echo 'export PATH=$HOME/.brew/bin:$PATH' \u003e\u003e $HOME/.zshrc \u0026\u0026 source $HOME/.zshrc \u0026\u0026 brew update\n```\n\nInstall Readline library:\n```\nbrew install readline\n```\n\n```\nbrew link --force readline\n```\n\n```\necho 'export C_INCLUDE_PATH=\"$HOME/.brew/include:$C_INCLUDE_PATH\"' \u003e\u003e ~/.zshrc\n```\n\n```\necho 'export LIBRARY_PATH=\"$HOME/.brew/lib:$LIBRARY_PATH\"' \u003e\u003e ~/.zshrc\n```\n```\nsource ~/.zshrc\n```\n\n## Run tests\n\nTo check if your minishell build was succesful you can run a tester, which compares most of the features with your current Bash installation. The test compares the stdout and the exit-code directly and checks in case of an error if both print something in stderr. \n\n```\nmake test\n```\n\n## Activate debug mode\n\nEnter minishell and export the DEBUG env:\n\n```\nexport DEBUG=printer\n```\n\nFor all next commands you will execute in the minishell you will see the different processing steps from the lexer and parser with syntax highlighting.\n\n## Change the command line prompt\n1. Enter the SHELL\n```\n./minishell\n```\n2. Export the PS1 env (also works in Bash and other similar shells)\n```\nexport PS1='enter your prompt wish...$ '\n```\n\n\n\u003cbr\u003e\n\u003chr\u003e\n\u003cb\u003e*All 42 projects must be written in C (later C++) in accordance to the 42 School Norm.\u003cbr\u003e\u003c/b\u003e\n\u003cbr\u003e\n\n\u003e #### Sample restrictions:\n\u003e - All variables have to be declared and aligned at the top of each function\n\u003e - Each function can not have more then 25 lines\n\u003e - Projects should be created with allowed std functions otherwise it is cheating\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftjensen42%2F42-minishell","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftjensen42%2F42-minishell","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftjensen42%2F42-minishell/lists"}