Skip to content

Develop a basic Bash shell in C with features like command parsing, built-in functions, and support for piping and redirection, while learning shell operations, process management, and system calls.

Notifications You must be signed in to change notification settings

lai-jia-jing/minishell

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

minishell

Minishell is a collaborative project from 42 School designed to teach students how to create a fundamental shell program using the C programming language. This project involves implementing key shell functionalities such as handling redirections and pipes, expanding environment variables, and supporting several built-in commands. These built-ins include cd for navigating directories, echo for displaying messages, env for listing environment variables, exit for terminating the shell, export for managing environment variables, pwd for printing the current directory, and unset for removing variables from the environment.

Final score

125%

Usage

Clone the repository and compile:

cd minishell && make
cd minishell && make bonus

To run the program:

./minishell

When the shell starts, a prompt will appear, allowing you to enter commands to be executed.

Mandatory

Minishell includes essential shell functionalities, such as:

  • Prompt Display: Displays a prompt, awaiting commands from the user.
  • Built-in Commands: Implements echo, cd, pwd, export, unset, env, and exit functionalities.
  • Executable Resolution: Locates and executes programs using $PATH or specified relative/absolute paths.
  • Redirections and Pipes: Supports operators like |, <, >, <<, and >>, mimicking Bash behavior.
  • Environment Variable Handling: Processes $ variables and evaluates $? for the status of the last command.
  • Signal Management: Responds to Ctrl+C, Ctrl+D, and Ctrl+\ with behavior similar to Bash.
  • Command History Navigation: Allows users to browse through their command history using the arrow keys.

Bonus

The project additionally offers bonus features to enhance the shell experience:

  • Advanced Line Editing: Provides features like text cutting, copying, and pasting, along with word-by-word navigation via readline.
  • Logical Operators: Enables the use of && and || for command chaining.
  • Wildcard Expansion (*): Includes support for expanding wildcard patterns.
  • Exit Code Display: Shows the current exit code in the Minishell prompt.
  • Current Directory Display: Displays the current working directory in the prompt.

About

Develop a basic Bash shell in C with features like command parsing, built-in functions, and support for piping and redirection, while learning shell operations, process management, and system calls.

Topics

Resources

Stars

Watchers

Forks