Skip to content

JBalwaySUS/seashell

Repository files navigation

seashell

A custom shell implementation in C

Execution Instructions

  1. Clone the repository

    git clone https://github.com/OSN-Monsoon-2024/mini-project-1-JBalwaySUS.git
    
  2. Compile the executable

    make all
    
  3. Run the excutable

    ./a.out
    

Specification-wise Limitations/Assumptions

Part A

Specification 2: Input Requirements

Size of input buffer is 4096 characters i.e. for multiple commands or for single a single long command, the max no. of characters in one line of input can only be 4096 characters.

Specification 4: reveal

Using the '-l' flags reports the file size in terms of 1KB blocks like ls in bash. It receives the no. of 512-Byte Blocks from the sys/stat.h structure field st_block and divides it by 2 to display the same no. of blocks as ls -l in bash

Specification 5: log commands

  1. A log file is created at the directory where the shell is invoked from and the log is persistant for shells invoked from the same directory

    For eg:

    If shell is invoked from /home/username/, a mysh.log is created at /home/username/ and the log commands persist for any shell invoked from this directory even if they are run after chnaging directories.

    But if shell is invoked from /home/username/seashell, a new log file is created at this directory and the commands in this mysh.log will be unique from the one in /home/username

  2. The log file also stores commands which resulted in an error.

Specification 7: proclore

The Virtual memory field displays the memory used by the process in Bytes.

Specification 8: seek

Using the -e flag on a file tries to execute the file or directory as specified but if it fails to do so, it tries to print out the contents of the file. Upon failure of both only does it print "Missing permissions for this task!" to stderr

Part B

Specification 9: .myshrc

Aliases

  1. Definition of an alias must begin with the keyword alias followed by the alias name = command to be aliased. For eg:
    alias reveala = reveal -a
    
  2. The log file stores the alias without any modifications.
  3. The maximum number of aliases that can be stored is 4096.

Functions

  1. Definition of a function must begin with the keyword func followed by the function name and the command to be executed is enclosed within {} on separate lines. For eg:
    func revealall() 
    {
        reveal -a
    }
    
  2. The log file stores the function name without any modifications.
  3. The maximum number of functions that can be stored is 4096.

Specification 10: I/O Redirection

  1. I/O Redirections assumes that files dont have to be written and appeneded to in the same command. For eg: cat < file1 << file2 is not supported.

  2. I/O Redirection assumes the next argument after the redirection operator (i.e. <, > or >>) is the file to be read from or written to.
    And this file must be at the end of the command.

Specification 11: Pipes

  1. The piping is done sequentially i.e. the first command is executed and then the output is piped to the next command.
    Unlike bash, the commands are not executed in parallel.

  2. Background processes cannot be piped into other commands. For eg: cat file.txt & | wc is NOT supported.
    But the last command in a pipe can be a background process. For eg: cat file.txt | wc & is supported.

Specification 12: Redirection along with pipes

Rediraction is done before piping i.e. the output of the redirection is piped to the next command.
Therefore if output is redirected to a file, the next command in the pipe will not have any output to work with.

Specification 13: activities

  1. The maximum number of background processes that can be launched is 4096 over the span of a single terminal session.

  2. The activites stores the process id and the command that was run.
    It does not store any arguments that were passed to the command.

Specification 14: Signals

ping assumes all commands are of the form:

ping <pid> <signal>

i.e. multiple signals cannot be sent in a single command.

Specification 15: fg and bg

  1. Similar to ping, fg and bg assume all commands are of the form: fg <pid> or bg <pid> i.e. typing fg or bg without a pid will not work like in bash.

  2. A background process does not have access to the terminal and bringing such a process to the foreground, will cause the process to run in foreground with no access to STDIN or STDOUT

    Similarly, a foreground process cannot be run in the background using bg doing so hijacks the terminal.

Specification 16: Neonate

If not time is specified using -n, the default time is 1 second.

Part C

Specification 17: iMan

iMan only searches for the first argument in the command and displays the online manual for that command.
All other arguments are ignored.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published