Skip to content

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.

License

Notifications You must be signed in to change notification settings

hima890/simple_shell

Repository files navigation

Simple Shell Project

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.

Table of Contents

  1. Requirements
  2. Compilation
  3. Testing
  4. Tasks
  5. Authors
  6. Project Structure

Requirements

General

  • 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

Output

  • The shell must produce the same output and error messages as /bin/sh

GitHub

  • One project repository per group, avoiding duplicate repository names
  • Collaborators should be added to the repository to avoid score deduction

List of Allowed Functions and System Calls

Compilation

Compile the shell using the following command:

gcc -Wall -Werror -Wextra -pedantic -std=gnu89 *.c -o hsh

Testing

Interactive Mode

$ ./hsh
($) /bin/ls
hsh main.c shell.c
($)
($) exit
$

Non-Interactive Mode

$ 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
$

Tasks

Task 0: Betty would be proud

  • Write a beautiful code that passes the Betty checks

Task 1: Simple shell 0.1

  • 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

Task 2: Simple shell 0.2

  • Extend the shell to handle command lines with arguments

Task 3: Simple shell 0.3

  • Extend the shell to handle the PATH
  • Do not call fork if the command doesn't exist

Task 4: Simple shell 0.4

  • Implement the exit built-in to exit the shell

Task 5: Simple shell 1.0

  • Implement the env built-in to print the current environment

Task 6: Simple shell 0.1.1

  • 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

Task 7: Simple shell 0.2.1

  • Avoid using strtok in the shell implementation

Task 8: Simple shell 0.4.1

  • Modify the exit built-in to handle exit status as an integer argument

Authors

  • List all individuals who contributed to the repository in the AUTHORS file. Follow the format used in Docker.

Project Structure

/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/

About

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.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published