42 Project
We were asked to make our own shell, replicating basic functionalities. Everything was coded in C, respecting Norminette code convention.
- Tokenize: builds the Command Table (simple commands, IO files) from command line input. Handles input syntax errors.
- Executor: redirects IO and creates pipes if needed. Forks if launching an executable. Handles built-in commands errors.
- We don't have a MULTIOS option enabled by default, as is the case in zsh.
Expand
- malloc
- free
- write
- open
- read
- close
- fork = Creates a child process. Why is fork used?
- wait = Stops the parent process until the child process exit.
- waitpid = The waitpid() function shall be equivalent to wait() if the pid argument is (pid_t)-1 and the options argument is 0. Otherwise, its behavior shall be modified by the values of the pid and options arguments.
- wait3, wait4 = Obsolete.
- signal = Sets a function to handle a signal.
- kill = Sends a signal to a process or a group of processes.
- exit = Terminates a process immediately, special handle for child processes.
- getcwd = Saves the pathname of your current working directory in a string.
- chdir = Changes your current working directory.
- stat, lstat, fstat = Returns information about a file.
- stat = Standar.
- lstat = For symbolic links.
- fstat = Gets the file from a file descriptor.
- execve = Executes a program referred by a variable. (How to use)
- dup = Creates a copy of a file descriptor using the lowest numbereded unused descriptor.
- dup2 = Creates a copy of a file descriptor using the descriptor number given by the user.
- pipe = It's used to create inter-process communication. Interface in minishell?
- opendir = Opens a directory stream.
- readdir = Returns a pointer to a dirent structure representing the next directory entry in the directory stream.
- closedir = Closes the directory stream.
- opendir, readdir, closedir example here
- strerror = Returns an error message.
- errno = Number of last error, its a variable.
- Project has only been tested and runned on macOS systems
- Clone the repo
git clone https://github.com/its-a-maxi/minishell.git
- Compile
make
- Run minishell
./minishell
Maximo Monroy - monroy.vds@gmail.com
Alejandro León - https://github.com/ElHuaco
Project Link: https://github.com/its-a-maxi/minishell
- There is a github repository that obeys the order of proceedings pretty nicely.
- Please make sure to do a
lexer
->parser
->expander
->executor
to make your life easier. Here is a solid start. - Make sure that you understand the shell syntax
- Making your own shell
- Subject
- A reference.
- Another one.
- Use of **envp in main
- Pipe and redirection algorithm for A|B|C|D > outfile < infile