Mohcine-Ghalmi / Minishell

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Minishell

Minishell bullet

What Is Minishell ? (subject)

Minishell refers to a minimalistic shell or command-line interface program for Unix-like operating systems.A shell is a user interface that allows users to interact with the operating system by executing commandsand managing various tasks.
A Minishell typically provides basic functionality similar to a standard shell, such as executing commands, handling input and output redirection, managing processes, and supporting various shell features like command history and tab completion. However, it may not have all the advanced features of a full-featured shell like Bash or Zsh.

Parts of a Minishell

The shell implementation is divided into three parts: The Parser, The Executor, and Shell Subsystems.

1- The Parser

The Parser is the software component that reads the command line such as “ls ­-al” and puts it into a data structure called Command Table that will store the commands that will be executed.

2- The Executor

The executor will take the command table generated by the parser and for every SimpleCommand in the array it will create a new process. It will also if necessary create pipes to communicate the output of one process to the input of the next one. Additionally, it will redirect the standard input, standard output, and standard error if there are any redirections.

3- Shell Subsystems

Other subsystems that complete your shell are:
● Environment Variables: Expressions of the form ${VAR} are expanded with the corresponding environment variable. Also the shell should be able to set, expand and print environment vars.
● Wildcards: Arguments of the form a*a are expanded to all the files that match them in the local directory and in multiple directories .
● Subshells: Arguments between `` (backticks) are executed and the output is sent as input to the shell.

Functions allowed in this project

Function Manual Page From lib Description
printf man 3 printf <stdio.h> write output to stdout
malloc man malloc <stdlib.h> allocate dynamic memory
free man 3 free <stdlib.h> free dynamic memory
read man 2 read <unistd.h> read from a file descriptor
write man 2 write <unistd.h> write to a file descriptor
open man 2 open <fcntl.h> open and possibly create a file
close man 2 open <unistd.h> close a file descriptor
fork man fork <unistd.h> create a child process
wait man wait <sys/wait.h> wait for process to change state
waitpid man waitpid <sys/wait.h> wait for process to change state
wait3 man wait3 <sys/wait.h> (obsolete) wait for process to change state, BSD style
wait4 man wait4 <sys/wait.h> (obsolete) wait for process to change state, BSD style
signal man signal <signal.h> ANSI C signal handling
kill man 2 kill <signal.h> send signal to a process
exit man exit <stdlib.h> cause normal process termination
getcwd man getcwd <unistd.h> get current working directory
chdir man chdir <unistd.h> change working directory
stat man 2 stat <sys/stat.h> get file status by pathname
lstat man lstat <sys/stat.h> get file status by pathname (for symlinks)
fstat man fstat <sys/stat.h> get file status by fd
execve man execve <unistd.h> execute program
dup man dup <unistd.h> duplicate a file descriptor
dup2 man dup2 <unistd.h> duplicate a file descriptor
pipe man pipe <unistd.h> create pipe
opendir man opendir <dirent.h> open a directory
readdir man readdir <dirent.h> read a directory
closedir man closedir <dirent.h> close a directory
strerror man strerror <string.h> return string describing error number
errno man errno <errno.h> number of last error
termcap man termcap, man termios <term.h> direct curses interface to the terminfo capability database

About


Languages

Language:C 97.8%Language:Makefile 2.2%