Skip to content
/ MBsh Public

My implementation of a simple shell for linux

Notifications You must be signed in to change notification settings

MaroB05/MBsh

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MBsh (MaroB Shell)

MBsh is a simple shell implemented in C, designed to execute external programs and parse command arguments. This project focuses on understanding the basics of shell functionality, with a minimalist approach to error handling.

Table of Contents

  1. Project Overview
  2. Features
  3. Installation
  4. Usage
  5. How It Works
  6. Known Issues and Limitations
  7. Future Improvements
  8. Contributing

Project Overview

MBsh provides a basic shell environment that executes external commands, similar to /bin/sh. It does not currently support internal commands like cd or exit, keeping the focus on external program execution and argument parsing.

Features

  • Program Execution: Runs external programs (e.g., /bin/ls, /bin/echo) with specified arguments.
  • Argument Parsing: Parses and passes command-line arguments to the programs.
  • Minimal Error Handling: Basic error handling to manage invalid commands or missing arguments.

Installation

  1. Clone the repository:

    git clone https://github.com/your-username/MBsh.git
  2. Navigate to the project directory:

    cd MBsh
  3. Compile the code:

    make compile

Usage

To start MBsh, run:

make run

or

./build/MBsh.out

How It Works

Step 1: Input and Parsing

  • MBsh reads user input and splits it into the program name and arguments.
  • Basic error checks are applied, such as handling empty input.

Step 2: Forking and Execution

  • MBsh uses fork() to create a new process for executing the program.
  • In the child process, execvp() is called to run the specified program with arguments.

Step 3: Error Handling and Continuation

  • Minimal error handling is in place for unrecognized commands or argument errors.
  • MBsh continues prompting for new commands unless terminated.

Known Issues and Limitations

  • No Internal Commands: Commands like cd and exit are not supported as internal shell commands.
  • Limited Error Feedback: Error handling is minimal, providing basic feedback on invalid commands.
  • No Redirection or Piping: Features like input/output redirection and piping are not implemented.

Future Improvements

  • Add Internal Commands: Implement internal commands, such as cd and exit.
  • Enhanced Error Handling: Provide more informative error messages and handle additional edge cases.
  • Support for Redirection and Piping: Enable support for >, <, and | operators.
  • Job Control: Allow commands to be run in the background with &.

About

My implementation of a simple shell for linux

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published