This project involves creating a simple UNIX command-line interpreter in C that mimics the basic functionalities of the shell (/bin/sh). The shell is designed to meet specific requirements and guidelines outlined below.
- Editors: vi, vim, emacs
- Compilation on Ubuntu 20.04 LTS using gcc with options -Wall -Werror -Wextra -pedantic -std=gnu89
- Files must end with a new line
- Use Betty style, checked with betty-style.pl and betty-doc.pl
- No memory leaks in the code
- No more than 5 functions per file
- Header files should be include guarded
- Use system calls only when necessary
- The shell must produce the same output and error messages as /bin/sh
- One project repository per group, avoiding duplicate repository names
- Collaborators should be added to the repository to avoid score deduction
Compile the shell using the following command:
gcc -Wall -Werror -Wextra -pedantic -std=gnu89 *.c -o hsh
$ ./hsh
($) /bin/ls
hsh main.c shell.c
($)
($) exit
$
$ echo "/bin/ls" | ./hsh
hsh main.c shell.c test_ls_2
$
$ cat test_ls_2
/bin/ls
/bin/ls
$
$ cat test_ls_2 | ./hsh
hsh main.c shell.c test_ls_2
hsh main.c shell.c test_ls_2
$
- Write a beautiful code that passes the Betty checks
- Implement a basic UNIX command line interpreter
- Display a prompt, wait for the user to input a command, and execute it
- Handle the "end of file" condition (Ctrl+D)
- Do not use the PATH or implement built-ins
- Handle errors appropriately
- Extend the shell to handle command lines with arguments
- Extend the shell to handle the PATH
- Do not call fork if the command doesn't exist
- Implement the exit built-in to exit the shell
- Implement the env built-in to print the current environment
- Write a custom getline function using a buffer to minimize calls to the read system call
- Use static variables and avoid using the getline function
- Avoid using strtok in the shell implementation
- Modify the exit built-in to handle exit status as an integer argument
- List all individuals who contributed to the repository in the AUTHORS file. Follow the format used in Docker.
/SIMPLE_SHELL
├── README.md
├── AUTHORS
├── .gitignore
├── LICENSE
├── Build/ # Directory for building the main code
│ ├── main.c # Main file
│ │── main.h # Header file for function prototypes
│ ├── function_1.c
│ ├── function_2.c
│ ├── function_3.c
│ ├── ...
│
├── utility/
│ ├── function1/ # Directory for function 1
│ │ ├── function1.c # Function 1 implementation
│ │ ├── function1.h # Function 1 header
│ │ ├── function1_test.c # Function 1 test
│ │ ├── function1_flowchart.png # Function 1 flowchart
│ │ ├── function1_pseudo.txt # Function 1 pseudo code
│ │
│ ├── function2/ # Directory for function 2
│ │ ├── function2.c # Function 2 implementation
│ │ ├── function2.h # Function 2 header
│ │ ├── function2_test.c # Function 2 test
│ │ ├── function2_flowchart.png # Function 2 flowchart
│ │ ├── function2_pseudo.txt # Function 2 pseudo code
│ │
│ ├── ...
├── man/ # Manual pages for your shell
│ ├── shell.1
├── flowcharts/ # Directory for general flowcharts
│ ├── general_flowchart.png # General flowchart for the shell
├── pseudo_code/ # Directory for general pseudo code
│ ├── general_pseudo.txt # Pseudo code for the shell
├── concepts/