Skip to content

ApurvPurohit/SeaShell

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Stargazers Issues MIT License


SeaShell

SeaShell

A custom Bash written in C
Report Bug · Request Feature


Table of Contents
  1. About The Project
  2. Features
  3. Usage
  4. Contribute
  5. License
  6. Contact
  7. Acknowledgements

About The Project

SeaShell is a custom Unix-type shell written in C. It emulates basic Bash specifications like batch-processing(shell scripts), piping, signal-handling, I/O redirection, etc and the history feature inspired from ksh and csh. Read more about Bash here.

Features

Display

Display Format: <username@system_name:curr_dir>

The directory from which SeaShell is invoked is the home directory, indicated by ~. If the user executes cd (change dir), the corresponding change is reflected in SeaShell as well.

E.g., >./SeaShell

<johndoe@loremipsum:~>cd newdir

<johndoe@loremipsum:~/newdir>

Batch-processing of Commands: SeaShell Scripting

  1. SeaShell supports processing of multiple batch files. They should be provided as space-seperated arguments while running the executable as:

./SeaShell <file-name1> <file-name2>

  1. After processing of batch files (if supplied), SeaShell goes to a post-processing interactive mode, similar to a unix-type shell.

  2. The batch file can contain user-defined as well as generic unix system commands. Sample Batch File

User-defined Commands

  1. HISTORY BRIEF - Lists out all the commands that were executed so far without the respective arguments, one command per line.

  2. HISTORY FULL - Lists out all the commands so far with their respective arguments. Each command has an INDEX number associated with it and it is displayed as well.

  3. HISTN - Lists last "N" commands executed by SeaShell. If the number of commands is less than "N", it prints only the available number of commands.

  4. !HISTN - Executes HISTORY command number "N" (assuming 1-indexing).

  5. EXEC <COMMAND_NAME> - Executes the user supplied command with its arguments.

  6. EXEC <COMMAND_INDEX_NUMBER> - Executes the command at user supplied index in HISTORY with its arguments.

  7. STOP - Terminates SeaShell.

  8. pid - Prints the process id of the SeaShell process.

  9. pid current - Lists the process ids of the processes that were spawned by SeaShell and are currently active.

  10. pid all - Lists the process ids of all commands that were executed so far by SeaShell (including the currently executing processes).

(All other commands are treated as system commands like ls, emacs, vi and so on.)

Context-specific Execution

  1. Foreground processes: Executing any command normally(in the foreground) implies that SeaShell will wait for the process to complete and regain control when the process exits.

  2. Background processes: Any command invoked with a & argument is treated as a background command. This implies that SeaShell will spawn the process and proceed(won't wait for the process to exit). When the background process exits, an appropriate indication message is shown to the user.

I/O Redirection

  1. Output redirection with >

<johndoe@loremipsum:~>wc temp.c > output.txt

<johndoe@loremipsum:~>cat output.txt

xx xx xx

  1. Input redirection with <

<johndoe@loremipsum:~>wc < temp.c

xx xx xx

  1. Input/Output redirection with <, >

<johndoe@loremipsum:~>wc < temp.c > output.txt

<johndoe@loremipsum:~>cat output.txt

xx xx xx

  1. Redirection with pipes (multiple pipes supported)

<johndoe@loremipsum:~>cat temp.c | wc | output.txt

xx xx xx

  1. Redirection with pipes and >

<johndoe@loremipsum:~>temp.c | wc > output.txt

<johndoe@loremipsum:~>cat output.txt

xx xx xx

Usage

  • Clone the repository and cd to repository root.
  • Run the Makefile(make).
  • Run the executable with/without batch file arguments (./SeaShell).

Contribute

Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated. Here's how you can contribute:

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

Distributed under the MIT License. See LICENSE for more information.

Contact

Ask me anything here.

Follow me around the web:
Apurv's Twitter   Apurv's LinkedIn

Acknowledgements