Git Product home page Git Product logo

anbash's Introduction

Shell emulator

Description

The program accepts shell commands from the standard input stream and executes them, handling errors.
Algorithm:
  1. The program reads commands of any length in parts using a buffer.
  2. Parses the input data and forms an array of tokens from them.
  3. Performs syntax validation. If the syntax is correct, go to step 4. Otherwise, it reports an error and returns to step 1.
  4. Builds a command tree based on the array.
  5. Executes commands from the tree, handling errors.
  6. Goes to step 1 while waiting for the next command.

The program processes the following special sequences: < > >> | || && & ; ( ) " ' \ # $SHELL $HOME $USER $EUID

Modules

It consists of 3 main modules:
  • shellexec (see below)
  • parse (see below)
  • main

It also uses following auxiliary modules:

  • colors (to learn more about it, see the module README.md)
  • strarr (to learn more about it, see the module README.md)
  • strarr_iter (to learn more about it, see the module README.md)
  • shelltree (to learn more about it, see the module README.md)

shellexec

`int shell_exec(ShTree *tree, int bg_pp, void (*emerg)(void));`
The function executes shell commands of tree and returns exit status; 'bg_pp' is a pipe for background process to remove zombies; 'emerg' is a function that is called in son after fork if execution is failed.

parse

`char ** parse(char **strarr);`
The function parses strarr for shell.
`ShTree * st_build(char **arr);`
The function creates and returns ShTree by parsed array.

anbash's People

Contributors

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