Minishell is a simple shell program written in C, providing a basic command-line interface for users to interact with their operating system. It supports various built-in commands and allows users to execute external programs as well.
- Command Execution: Execute shell commands and external programs.
- Argument Expansion Expands environment variables such s
$PATH, single quoted argument to literal string, double quoted argument to environment variable expanded string. - Built-in Commands: Supports a variety of built-in commands, including
cd,echo,env,exit,export,pwd, andunset. - Command Line Editing: Utilizes readline library for command line editing and history functionality.
- Signal Handling: Handles signals include
Ctrl+C[SIGINT] andCtrl+\[SIGQUIT]. - Input/Output Redirection: Supports input/output redirection with
<: input redirect,>: output redirect,>>: output redirect append,<<: heredoc. - Pipes: Allows piping of commands using
|operator. - Working history Use arrow
↑and↓to browse through history and retry commands.
- Clone the repository:
git clone https://github.com/theVeryPulse/Minishell.git
- Navigate into the cloned directory:
cd Minishell - Compile the program using make:
make
- Run the minishell executable:
./minishell
Once the minishell program is running, you can interact with it using various commands and features:
Built-in Commands
cd: Change directorycd /path/to/directory cd - # Goes back to previous directoryecho: Print arguments to standard output.echo $PATH echo $? echo '$USER 123' "$USER 123"env: Without arguments: print environment variables; with arguments: run program in modified environment (seeman env).env # prints all environment variables env PATH= ls # Set PATH to empty in a environment copy, then try running ls.exit: Exit minishellexit # return the value of the latest recorded exit status exit 123 # return specified valueexport: Add or modify environment variable values.export PATH= export a=1pwd: Print current directory.unset: Remove environment variable.
External Commands
Execute any external program by typing its name. Minishell searches for executable according to the PATH variable.
ls -l
Input/Output Redirection
Use <, >, <<, >> operators for input and output redirections.
cat < input.txt > output.txt
cat <<end >output1.txt | cat <<end >output2.txt
Piping
Pipe multiple commands together using the | operator. When there are pipes, all commands will be executed in child processes.
ls -l | grep .txt
cat file.txt | wc -l