Code Monkey home page Code Monkey logo

ksh's Introduction

ksh

It's a shell written in C.

Requirements

cmake, make and gcc are required to build and run ksh.

Installation instructions

  1. Clone the repo with git clone [email protected]:akcube/ksh.git.
  2. cd into the cloned directory cd ksh.
  3. Make a build directory and cd into it. mkdir build && cd build.
  4. Run cmake .. && make -j to build the binaries.
  5. You can now run the shell with ./bin/ksh.

Assumptions

  1. Commands are only upto 4096 characters long.
  2. History should not be deleted during shell execution. Will still function as normal but history will be lost.
  3. All commands must end with a & or ; or \n
  4. I assume proccesses with state R and S only are "Running" processes

Functionality

  • Displays prompt as <username@system_name:cur_dir>. cur_dir is the directory the shell was launched in.
  • Can execute ; spaced commands and ignores whitespaces and tabs.
  • Builtin commands:
    • cd
    • pwd
    • echo
    • pinfo
    • ls -[al]
  • Can execute system processes in foregroun and background and also keep track of them
  • Can repeat commands (even recursively!)
  • Implements history
  • Implements up arrow and bottom arrow key to access history dynamically
  • Input output redirection
  • Piping of multiple commands w/ redirection
  • jobs
  • fg, bg and sig
  • Signal handlers
  • Replay repeats commands in intervals of time t for a period p
  • Baywatch command

File structure

builtins.c contains code for the builtin functions, except ls. ls.c contains code for ls. error_handlers.c contains code for the error handlers. execute.c contains code for functions that execute both system and call builtin functions. history.c contains code for pushing logs into history. parsing.c contains code for parsing input lines read from terminal into Command structs and arg string vectors. proclist.c contains code for a doubly linked list that stores the list of active background processes. prompt.c contains code for reading input, up/bottom arrow keys and displaying prompt. shell.c contains the REPL loop. signal_handlers.c contains code for both installing the handlers and the handlers themselves. utils.c contains code for util functions used throughout the code. Noteworthy functions are init which sets up all the basic shell state resources and cleanup which frees resources and saves history to file. vector.c contains code for a string vector object that supports pushback, top, dynamic reallocation for O(1) amortized insertion, and sorting.

They've been heavily commented and the functions should be mostly self explanatory.

ksh's People

Contributors

akcube avatar

Stargazers

Praneetha Gokul 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.