Skip to content

flo-12/minishell

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

minishell

Thanks to Minishell, we were able to travel through time and come back to problems people faced when Windows didn’t exist.

The first bigger project in the 42 curriculum: recoding our own little bash. A program capable of parsing a prompt and launching executables with arguments, along with a few built-in functions.

MiniShell introduces us to the world of shells. It provides a convenient text interface to interact with the system. Shells might seem very easy to understand but have very specific and defined behaviour in almost every single case, most of which will need to be handled properly.

The output is still far from the original shell - especially because of the Hotfix period at the end of the project, but comes pretty close.

Thanks mvomiero for the collaboration on this project!

Screencast.Demo.minishell.webm

Learning goals

  • how does the concept of Lexer -> Parser -> Executor work
  • how do I structure a bigger project to work on it in a team
  • how is a shell set-up and how does it exactly work
  • using known patterns such as exit status in a bigger project
  • And of course how to collaborate on a project and split workload in an efficient way!

Core features of our shell are:

  • as simple as it is: the same as bash :-P
  • search and launch executables (with relative and absolute path)
  • working history
  • handle quotes and $ (dollar sign)
  • redirections (<, >, <<, >>)
  • pipes
  • environment variables
  • ctrl-C, ctrl-D and ctrl-\
  • builtins such as echo, cd, pwd, export, unset, env, exit
  • not crashing in any scenarios - sounds trivial, I know Sure, it's not a full-grown shell, but pretty close. So please bare some abstractions in the implementation.

Allowed external functions / libraries:

  • 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
  • Libft - own library with basic functions such as calloc, strncpm, etc. (see submodule)

As usual: All heap allocated memory space must be properly freed. No leaks will be tolerated.

Usage

Note that the program is written with Linux. Other operating systems were not tested.

Installing and Compiling

  1. Clone the repository and its submodule by git clone --recursive <project SSH/URL>
  2. direct to the cloned folder cd <folder_name>
  3. make (automatically compiles the Libft)

Execution

Simply run the minishell without arguments:

  • Example: ./minishell

Sources

Realizing this project requires a deeper understanding of the shell and the method of lexer/parser/executor. The following list is a recommendation of sources for anyone who wants to know more about the topic:

Topic Link
Official Bash Reference Manual (!!!) Bash Reference Manual
Knowldge base and useful links LinkTree Minishell
Writing Your Own Shell (extract from book) 2014 Gustavo Rodriguez-Rivera and Justin Ennen,Introduction to Systems Programming: a Hands-on Approach
Shell Command Language IEEE Std 1003.1, 2004 Edition
Overview from a 42 student MiniShell
detailed explenation of Unix-like OS MIT xv6: a simple, Unix-like teaching operating system
Tutorial: Write a Shell in C Stephen Brennan Blog
Tutorial on minishell zakaria oukaddour
List of possible Tests google.docs with tests

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published