As beautiful as a shell. Welcome to minishell! This repository contains a GNU like operating system, inspired by bash.
Mac OS
Minishell makes use of the GNU Readline library. To run the project, you will need to install this library. For Mac OS, the Readline library can be installed using Brew. If you already have Brew installed, skip to step 2.
# STEP 1: Install brew
rm -rf $HOME/.brew && git clone --depth=1 https://github.com/Homebrew/brew $HOME/.brew && echo 'export PATH=$HOME/.brew/bin:$PATH' >> $HOME/.zshrc && source $HOME/.zshrc && brew update# STEP 2: Install readline
brew install readlineLinux
Minishell makes use of the GNU Readline library. To run the project, you will need to install this library. For Linux, the Readline library can be installed using apt.
To simulate a Linux machine, emulators such as OrbStack are available for free.
# STEP 1: Install readline
sudo apt install libreadline-devTo run minishell, first compile the program using make. Whether using Mac OS or Linux, the make recipies do not differ.
make # Compile
make valgrind # Complie and monitor memory leaks
make re # Recompile
make clean # Compile and delete all object files
make fclean # Remove all objects and executables./minishell # Run executable
./minishell -p # Run executable in debug mode[minishell]:Each successive operation of the program displayes a new prompt.
^Using the up arrow will display the previous command.historyThe history command will list all previously entered commands.
' 'Single quotes do not expand contained input." "Double quotes expand the contained input.$The perameter or variable expansion operator is used to expand the value for a given key found in the program environment or evn.$?Exit code. Expand the exit code of the last executed command.
>Redirect output. Redirect the standard output of a command to a file. If the file does not exist, it is created. If the file does exist, contents are overwritten.>>Redirect append. Include multiple lines of input in a command. Given a delimiter, read the input until a line containing the delimiter is seen.<Redirect the standard input of a command from a file. It takes the contents of the file and proviedes the as an input for the command.<<Heredoc. Redirect the standard output of a command to a file, appended to the end of the contents of the file without overwriting. Heredoc reads until the given end of file or EOF. e.g.echo << EOF.
|A single pipe operator connects the output of one command to the input of another. By default, pipe sendsstdout(1)tostdin(0). The first command writes to an open file on the write fd, upon completion of the open process, the second command reads from the read fd of the open file.
ctrl-cEnds the current process and displays a new prompt on a new line.crtl-dKills all processes and exit the minishell program.
* man(1-3) General Commands Manual
| Builtin | Description |
|---|---|
echo |
The echo utility writes any specified operands, separated by single blank (‘ ’) characters and followed by a newline (‘\n’) character, to the standard output. |
pwd |
The pwd utility writes the absolute pathname of the current working directory to the standard output. |
cd |
The cd utility shall change the working directory of the current shell execution environment. |
env |
The env utility executes another utility after modifying the environment as specified on the command line. Each name=value option specifies the setting of an environment variable, name, with a value of value. All such environment variables are set before the utility is executed. |
export |
Minishell shall give the export attribute to the variables corresponding to the specified names, which shall cause them to be in the environment of subsequently executed commands. If the name of a variable is followed by =word, then the value of that variable shall be set to word. |
unset |
Each variable or function specified by the given key shall be unset in the environment. |
exit |
The exit() function causes normal process termination. |