You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

2.9 KiB

0-shell

Objective

The objective of this project is for you to create a simple shell.

Through the 0-shell you will get to the core of the Unix system and explore an important part of this system’s API witch is the process creation and synchronization. Executing a command inside a shell implies creating a new process, which execution and final state will be monitored by its parents process. This set of functions will be the key to success for your project.

For this project you will only have to create a simple Unix interpreter where you can run some of the most known commands. For this part of the project, no advanced functions, pipes or redirection will be asked, you can add them if you like.

Instructions

  • You must program a mini Unix interpreter.
  • This interpreter must display at least a simple $ and wait until you type a command line witch will be validated by pressing enter.
  • The $ will be shown again only once the command has been completely executed.
  • The command lines are simple, you will not have pipes, redirection or any other advanced functions.
  • You must manage the errors, by displaying a message adapted to the error output.
  • You must implement the following commands that will behave exactly like the originals:
    • echo
    • cd
    • ls
    • pwd
    • cat
    • cp
    • rm
    • mv
    • mkdir
    • exit
  • You must manage the program interruption Ctrl + D.
  • The project has to be written in a compiled language like (C, Rust, go or other), no semi compiled language like (Pearl and others) are allowed.
  • The code must respect the good practices

This project will help you learn about:

  • Shell
  • Operating systems services
  • Command-line interfaces
  • Unix system
  • Process creation and synchronization
  • Commands syntax
  • Scripting language

Bonus

You can also do more bonus features like:

  • Manage the interruption Ctrl + C
  • Auto complete when you are writing
  • Add piping
  • Add redirection
  • Have your path behind the $ like (~/Desktop/0-shell $)
  • Add colors for the directories or errors
  • Other advanced commands you may like.

Usage

student$ ./0-shell
$ cd dev
$ pwd
dev
$ ls -l
total 0
crw-------  1 root   root     10,    58 fev  5 09:21 acpi_thermal_rel
crw-r--r--  1 root   root     10,   235 fev  5 09:21 autofs
drwxr-xr-x  2 root   root           540 fev  5 09:21 block
crw-------  1 root   root     10,   234 fev  5 09:21 btrfs-control
drwxr-xr-x  3 root   root            60 fev  5 09:20 bus
drwxr-xr-x  2 root   root          4400 fev  5 09:21 char
crw-------  1 root   root      5,     1 fev  5 09:21 console
lrwxrwxrwx  1 root   root            11 fev  5 09:20 core -> /proc/kcore
drwxr-xr-x  2 root   root            60 fev  5 09:20 cpu
crw-------  1 root   root     10,    59 fev  5 09:21 cpu_dma_latency
$ something
Command 'something' not found
$ echo "Hello There"
Hello There
$ exit
student$