A small Unix shell written in C. It handles tokenizing, parsing, expanding variables, redirections, pipelines, and command execution. The project is inspired by the behavior of Bash, implementing a simplified version of its core features.
minishell reads user input, breaks it into tokens, builds command structures, applies expansions, and executes commands using POSIX system calls. It supports basic shell features like pipes, redirections, and environment variable management.
- Tokenizer + lexer
- Parser for simple commands & pipelines
- Environment variable management
- Word/variable expansion
- Redirections (
>,>>,<) - Pipelines (
cmd1 | cmd2 | cmd3) - Builtins
git clone https://github.com/procrastinator-101/minishell.git
cd minishell
make
./minishellminishell uses the readline library for command-line input.
If you don't have readline installed on your system, you need to install it and update the Makefile paths accordingly.
brew install readlinesudo apt-get install libreadline-devIn the Makefile, update the LIBS and INCLUDES variables to point to your readline installation path:
LIBS = /path/to/readline/lib
INCLUDES = /path/to/readline/include
For example, on macOS with Homebrew, it might look like:
LIBS = /Users/$(USER)/.brew/opt/readline/lib
INCLUDES = /Users/$(USER)/.brew/opt/readline/include
Then run make re to build the project with readline support.
make # build
make clean # remove object files
make fclean # full clean (including binary)
make re # rebuildRun ./minishell to start the shell. Enter commands as you would in a standard Unix shell.
$ ls -la
$ echo $HOME
$ echo "hello" > out.txt
$ cat file.txt | grep abc | wc -l
$ export MYVAR=ok
$ echo $MYVAR
Type exit to quit the shell, or press Ctrl + D.