Skip to content

A user-defined Unix-based interactive shell program in C which supports all the shell commands

Notifications You must be signed in to change notification settings

Amogha027/Linux-Shell

Repository files navigation

Name : Amogha A Halhalli

Roll No. : 2021101007


USER-DEFINED INTERACTIVE SHELL PROGRAM

Running the shell :

From the folder containing all the files, run

make

followed by

./main

Supporting Files :

  • main.c
    Read commands from the terminal and call appropriate functions.
    Considers the directory from which the shell is invoked as the home directory.

  • echo.c
    Prints user input after removing excess spaces/tabs.
    Does not handle quotes and environmnetal variables.
    If & or ; is encountered, then the input after & or ; is read as next command.

  • cd.c
    Change to the directory specified by the user.
    Accepts only one argument after cd as first argument.

  • pwd.c
    Prints the absolute path of the current working directory.

  • ls.c
    Lists all the files and directories of the user specified directory.
    Supports multiple directories; flags handled are -a and -l.

  • history.c
    Prints the latest 10 commands entered by the user.
    If there are fewer than 10 commands, prints all of them.

  • input.c
    Uses rawmode to read input from stdin character by character.
    Supports autocompletion when 'tab' is entered.

  • discover.c
    Search for file/directory in a user specified directory.
    Name of the file/directory to be found is given in quotes.
    Flags -d and -f lists all directories and files respectively.

  • pinfo.c
    Prints the information of a process with given process ID.
    If process ID not given, considers the current running process.

  • prompt.c
    Prints the appropriate prompt after the execution of every command.
    Prints the time taken for the foreground processes.

  • process.c
    Executes all other background processes.
    Time taken is displayed by the prompt after its execution.

  • bProcess.c
    Executes the command preceding '&' as background processes.
    Prints the process ID of the process at the start of its execution.
    Prints process ID and exited normally/abnormally after the execution.

  • signal.c
    handler : Print the finished background processes along with their process ID.
    ctrl_c : Interrupt any currently running foreground job, by sending it the SIGINT signal.
    ctrl_z : Push any currently running foreground job into the background, and change its state from running to stopped.

  • jobs.c
    Prints a list of all currently running background processes entered by the shell in alphabetical order.
    Each line contains job number, process ID and their state(running or stopped).
    Flags handled are -r for running processes, -s for stopped processes and both(if not mentioned).

  • fbs.c
    sig : Sends the corresponding signal to the process with given job number.
    fg : Brings the running or stopped background job of given job number to the foreground and changes its state to running.
    bg : Changes the state of a stopped background job to running in the background.

Assumptions :

  • The length of each input command should be less than 500.
  • The user is logged out of the terminal on entering ctrl_d.
  • The commands with &, | and ; are also considered as valid input commands.
  • The output of commands, usually written to stdout, can be redirected to another file.
  • The input taken from a file other than stdin, both input & output redirection can be used simultaneously.
  • Using < for read, > for write and >> for append, output file is created if it does not exist already.
  • It is assumed that there exists a command between two &'s, two |'s or two ;'s in the input.
  • The file headers.h contains all the header files and preprocessor directives.
  • Some global structs which are used are also defined in the file headers.h
  • The user commands are stored in a file history.txt for the command history.
  • The user is not allowed to change the contents of the file history.txt
  • The names of files and directories should not contain special characters.
  • Any error in the execution of commands will stop the execution and print error message.
  • Specific color coding is used for error messages, prompt, directories, executable files, etc.

About

A user-defined Unix-based interactive shell program in C which supports all the shell commands

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages