Skip to content

This group project involves recreating a simplified version of the Bash shell, focusing on interpreting and executing user commands. Key features include parsing and executing built-in commands, managing processes, handling signals, and supporting essential shell functionalities like input/output redirection and pipelines.

Notifications You must be signed in to change notification settings

arinatyurina/minishell

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

79 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Minishell

Introduction

The Minishell project, part of the 42 School curriculum, aims to provide an in-depth understanding of shell functionality and system calls in Unix-like operating systems. This group project was divided into two main parts: the parser and the executor. The parser is responsible for interpreting and structuring user input, while the executor manages the execution of commands, including handling pipes and redirections. Our implementation is based on the behavior of Bash, ensuring a user experience that is both familiar and functional.

minishell

Setup

  1. Clone the repository:

    git clone https://github.com/arinatyurina/minishell.git
  2. Compile the program:

    make

Usage

To run the minishell program, simply execute the compiled binary:

./minishell

Once running, you can enter commands as you would in a typical Unix shell. For example:

minishell$ ls -l
minishell$ cat file.txt
minishell$ echo "Hello, World!"
minishell$ exit

Example

minishell$ ls -l | grep minishell > output.txt

This command will list files in the current directory, pipe the output to grep minishell, and write the result to output.txt.

Features Overview

Command Execution

Execute basic commands such as ls, grep, wc, cat, etc. Support command-line arguments and options.

Redirections

Redirect input and output using <, >, >>. Manage complex operations with redirections using pipes (|).

Built-in Commands

  • cd (Change Directory): Navigate through directories using cd.
    Examples: cd /path/to/directory: Change to a specific directory.
    cd ..: Move up one directory level.

  • pwd (Print Working Directory): Show the current working directory path.
    Example: pwd: Output the current directory path.

  • echo (Output): Display messages and variable values with echo.
    Examples: echo Hello, World!: Output a simple message.
    echo $PATH: Display the current value of the PATH variable.

  • export: Set environment variables for use in subsequent commands.
    Example: export PATH=/usr/bin: Set the PATH variable to /usr/bin.

  • unset: Remove environment variables from the current shell session.
    Example: unset PATH: Remove the PATH variable from the environment.

  • env: Display all environment variables.
    Example: env: List all environment variables and their values.

  • exit: Terminate the shell session.
    Example: exit: Exit the shell.

Error Handling

Provide clear and informative error messages across various scenarios.
Ensure proper handling of exit statuses for child processes.

Control Flow

Integration of commands with support for pipes.
Manage command execution within pipelines for efficient processing.

Heredoc

Implement heredoc functionality to support multiline input and scripting.
Manage interruptions with support for Ctrl+C and Ctrl+.

Signal Handling

Responsively handle signal Ctrl+C.

About

This group project involves recreating a simplified version of the Bash shell, focusing on interpreting and executing user commands. Key features include parsing and executing built-in commands, managing processes, handling signals, and supporting essential shell functionalities like input/output redirection and pipelines.

Resources

Stars

Watchers

Forks