Skip to content

assam4/Shell_Basic_Implementation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

156 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This project is a custom implementation of a shell, similar to bash or zsh. It is a school project that aims to create a simple yet functional command-line interpreter.

About The Project

The Minishell project is a classic exercise in system programming. It involves parsing user input, managing processes, and interacting with the operating system's kernel. This implementation is written in C and uses the readline library for input handling.

The project is structured into several modules:

  • shell/: Core shell functionality, history, and utilities.
  • environment/: Environment variable management.
  • runtime/: Command execution, redirection, and expansion.
  • lexical_a/: Lexical analysis and tokenization.
  • syntax_a/: Syntax analysis and here-doc handling.
  • builtins/: Implementation of built-in commands like cd, echo, pwd, etc.
  • optimization/: Command and here-doc optimization.
  • library/: Contains libft and get_next_line.

How To Install

To get a local copy up and running, follow these simple steps.

Prerequisites

You need to have git and make installed on your system. You also need the readline library.

On Debian/Ubuntu, you can install it with:

sudo apt-get install libreadline-dev

Installation

  1. Clone the repo
    git clone https://your_repo_link/minishell.git
    
  2. Navigate to the project directory
    cd minishell
    
  3. Compile the project
    make
    

This will create the minishell executable in the root directory.

How To Use

To start the shell, run the following command:

./minishell

You will be greeted with a new prompt, ready to accept your commands.

Examples

Here are some examples of what you can do with Minishell:

  • Simple commands

    ls -l
    
  • Pipes

    cat file1 | grep "hello"
    
  • Redirections

    ls > file.txt
    cat < file.txt
    
  • Here-doc

    cat << EOF
    hello
    world
    EOF
    
  • Built-in commands

    echo "Hello, World!"
    cd /path/to/dir
    pwd
    export VAR="value"
    unset VAR
    env
    exit
    

Cleaning Up

To remove the object files, run:

make clean

To remove the object files and the minishell executable, run:

make fclean

About

Minishell is a simplified Unix shell written in C, developed as a project to deepen understanding of how shells work internally. It replicates core features of a real shell like bash or zsh, including command parsing, process execution, environment variable handling, and I/O redirection.

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors