Giter VIP home page Giter VIP logo

bosh's Introduction

Bosh

A simple Unix shell that probably won't blow up your system

Build Status

Bosh is a minimal Unix shell that allows for basic command interpretation and execution. It supports process communication via pipe redirects (|) in addition to file redirects (> and <) and backgrounding (&).

Bosh is written in ~400 lines of clean C with almost as many lines of comments. It was implemented as part of the Operating Systems and C course at the IT University of Copenhagen and turned out to be a most interesting introduction to both the C language and process management in Unix-like systems.

Installation

Bosh has no external dependencies so assuming that you have CMake and a C compiler available on your system, Bosh can be installed using the following command:

$ cmake . && make install

This will compile Bosh and install its binary on your $PATH.

Architecture

The overall architecture of Bosh is very much inspired by Bash and is split into four major components:

  • Prompting
    As one would expect of a shell, the first step in executing a command is prompting the user for input. Where Bash uses the rather bloated Readline library for handling user input, this step is in Bosh handled by the Linenoise library that you'll find included in the lib/ directory.

  • Lexical analysis
    Once the user has inputted one or more commands, a small, hand-written lexer takes care of splitting the input up into tokens. Each token is described by a struct that stores the type and optional value of the token. The result of the lexical analysis is a linked list of these tokens.

  • Word expansion
    Prior to parsing, the lexed tokens are expanded (e.g. expanding ~ to the home directory of the user) where applicable.

  • Parsing
    Once the user input has been split up into tokens, these tokens are then parsed to individual commands and their associated redirects. Each command is like the tokens described by a struct that stores the program, arguments, I/O redirects, and backgrounding flag of the command. The result of the parsing is a linked list of these commands.

  • Execution
    The final step is execution of the parsed commands. For each command, the executor takes care of setting up the pipe redirects and file redirects after spawning a separate process that will be used for executing the program specified by the command.

License

Copyright © 2016-2017 Kasper Kronborg Isager. Licensed under the terms of the MIT license.

bosh's People

Contributors

kasperisager avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  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.