simple shell project

  • In this project we are tasked to write a simple UNIX command interpreter like sh (/bin/sh)

  • We have 5 mandatory task:
  1. Handle command lines without arguments
  2. Handle command lines with arguments
  3. Handle the PATH
  4. Implement the exit built-in
  5. Implement the env built-in


  • This project follow betty style for a clean code .

Output

  • This program must have the exact same output as sh (/bin/sh) as well as the exact same error output.
  • The only difference is when you print an error, the name of the program must be equivalent to argv[0]
  • This shell work in interactive mode and in non-interactive mode

Compilation and Run

  • This shell will be compiled this way: gcc -Wall -Werror -Wextra -pedantic -std=gnu89 *.c -o hsh
  • Run: ./hsh

System calls

  • In this project we use the following system call:

access execve exit fork free getline getpid isatty malloc perror read stat strtok wait

Learning Objectives

  • In this project we learned:

  • Who designed and implemented the original Unix operating system

  • Who wrote the first version of the UNIX shell

  • Who invented the B programming language (the direct predecessor to the C programming language)

  • Who is Ken Thompson

  • How does a shell work

  • What is a pid and a ppid

  • How to manipulate the environment of the current process

  • What is the difference between a function and a system call

  • How to create processes

  • What are the three prototypes of main

  • How does the shell use the PATH to find the programs

  • How to execute another program with the execve system call

  • How to suspend the execution of a process until one of its children terminates

  • What is EOF / “end-of-file”?

Contributors