Git Product home page Git Product logo

small-shell's Introduction

Small Shell - Custom Shell Implementation in C

Introduction

This project implements a custom shell in C. The shell provides a subset of features similar to well-known shells like bash. It allows users to run commands, handle blank lines and comments, expand variables, execute built-in commands, execute other commands via processes, support input/output redirection, run commands in foreground and background processes, and implement custom signal handlers.

Description

This custom shell designed to provide basic shell functionalities such as executing commands, managing processes, handling signals, and supporting input/output redirection. It is developed in C and aims to replicate key features of popular Unix shells like bash.

Key Components

  1. Command Prompt: Utilizes the colon : symbol as a prompt for each command line. Supports command syntax with optional input/output redirection and background execution.
  2. Built-in Commands: Supports three built-in commands: exit, cd, and status. Handles execution of built-in commands separately from external commands.
  3. Execution of Other Commands: Executes non-built-in commands using fork(), exec(), and waitpid(). Utilizes the PATH variable to locate non-built-in commands.
  4. Input & Output Redirection: Redirects input/output using dup2() before executing the command. Handles errors if files cannot be opened for input/output redirection.
  5. Foreground & Background Execution: Runs commands in foreground or background based on the presence of &. Prints process IDs and exit statuses for background processes.
  6. Signal Handling: Handles SIGINT and SIGTSTP signals appropriately for foreground and background processes. Displays informative messages and manages shell behavior based on signal reception.

Compilation Instructions

To compile the shell, follow these steps:

  1. Open a terminal.
  2. Navigate to the directory containing the source code files.
  3. Use the gcc compiler to compile the code:
    gcc -o smallsh small_shell.c
  4. Upon successful compilation, an executable file named smallsh will be created in the same directory.
  5. Download the testing script provided in this repository and run the command:
    ./smallsh

small-shell's People

Contributors

mfaks avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.