my bell, sont des mots qui ...

Problem specification

A shell is an interactive program that interprets user commands for the operating system (i.e. Linux). The commands are entered on a command line interface and each command can be specified with some options and arguments. Linux provides different shells (e.g. bourne, csh, tcsh, bash, korn,…) that can handle mostly the same commands with some syntactical differences. In addition, the user can also implement his (or her) own shell to fit his (or her) particular needs.

System calls represent calls to functions that are implemented in the kernel of the Linux operating system. The programmer must use system calls in order to request system services because he (or she) is restricted direct access to the system resources for protection and security reasons.

You are required to write a C language program that will be used as a command shell for file management and program launches. You must use Linux system calls and commands for file and for process management to implement the functionalities of your shell. You should name the program imchell. Your program will behave quite similarly to the Linux shell bash and should display a prompt (i.e. imchell>) at start-up. The user should then enter one of the shell commands (with appropriate options and arguments) at the prompt followed by Enter, and the shell should again display the prompt after processing the command. If a command is invalid the shell should display an appropriate error message. In order to compile and link your program, you will need to implement a makefile.

Minimal functionnalities

The following command lines must be correctly executed by your program (assuming cmd to be the name of an executable file, given either with the absolute path or relative):
  • cmd : create a new process which will execute cmd
  • cmd & : create a new process which will execute cmd in background
  • cmd > file : create a new process which will execute cmd with the standard output file descriptor changed by file given
  • cmd 2> file : idem with the standard error
  • cmd < file : idem with the standard input
  • cmd1 | cmd2 : create 2 new process with cmd1 standard output redirect to cmd2 standard input
  • cmd1 ! cmd2 : create 2 new process with cmd1 standard output redirect to cmd2 standard input and cmd2 standard output redirect to cmd2 standard input (note that this feature does not exist with bash - but exists with other shell languages
  • var=value : add variable var to a set of internal variables with value value. In following command lines resolution, the string "$var" must be replaced by "value"
  • export var : add internal variable var to the environment
  • help : internal command that prints help
  • cd dir : internal command that prints the current working directory
  • exit : internal command that terminates the program

You are free to implement any additional functionalities (gesture of variable PATH to retrieve executable files, script interpretor, conditional command lines (&& || ..) etc.)

What you have to do, to send, and when:

You have to send to me, by February 17, an archive named login.tgz (where login is your esiee login), containing:
  • a directory "src" with the code source
  • an empty directory "bin"
  • a file "makefile", the command make must compile the src and produce an executable file in directory "bin" (search help on google...)
  • a directory doc containing two pdf files : user.pdf and dev.pdf.
    • user.pdf is a manual that explain the functionalities of your program, how to compile it, to run it and to use it. It also report the bugs and any other information useful to the fictive user of your program
    • dev.pdf is a document that explain the technical choices you have made, the structure of the code, and any information useful to a programmer whose want to extend the functionalities of your project.
All the code you provide must be written by you