Giter VIP home page Giter VIP logo

simple_shell's Introduction

Holberton School

Simple Shell ๐Ÿค–

Introduction

This repository contains the files to simulate a basic Unix Shell with its respective commands.

Description

This repository contains the executable files to simulate a simple Unix shell with its respective basic commands as well as some advanced ones developed by the contributors. Each functionality of the file will be commented, as well as each line of the function where its compression is not so clear to the naked eye.
In the Shell you can interact both in interactive and non-interactive mode (explanation and examples in Modes.

Requeriments

  • Programs and functions will be compiled with gcc using the flags -Wall -Werror -Wextra -pedantic and -std=gnu89
  • All files should end with a new line
  • No more than 5 functions per file
  • Operating System: Ubuntu 20.04 LTS
  • Compiler: GCC
  • Authorized functions and system calls:
    • access (man 2 access)
    • chdir (man 2 chdir)
    • close (man 2 close)
    • closedir (man 3 closedir)
    • execve (man 2 execve)
    • exit (man 3 exit)
    • fork (man 2 fork)
    • free (man 3 free)
    • stat (__xstat)(man 2 stat)
    • lstat (__lxstat)(man 2 lstat)
    • fstat (__fxstat)(man 2 fstat)
    • getcwd (man 3 getcwd)
    • getline (man 3 getline)
    • kill (man 2 kill)
    • malloc (man 3 malloc)
    • open (man 2 open)
    • opendir (man 3 opendir)
    • perror (man 3 perror)
    • read (man 2 read)
    • readdir (man 3 readdir)
    • signal (man 2 signal)
    • strtok (man 3 strtok)
    • wait (man 2 wait)
    • waitpid (man 2 waitpid)
    • wait3 (man 2 wait3)
    • wait4 (man 2 wait4)
    • write (man 2 write)
    • _exit (man 2 _exit)
    • isatty (man 3 isatty)
    • fflush (man 3 fflush)

Flowchart

Below you can see the flowchart, which was taken as a starting point to carry out the code and each of its functionalities flowchar

Usage ๐Ÿ’ป

All the files are to be compiled on an Ubuntu 20.04 LTS machine with:

gcc -Wall -Werror -Wextra -pedantic -std=gnu89

Once compiled, to start the program, run: ./hsh

To exit the program, run: $ exit

List of Files

Function Name Description
shell.h Declaration of all functions to be used in the shell, as well as libriaries
shell.c Principal function
buildin.c Contains exit function, string to integer converter and buildin checker
path.c Contains the functions of: global variable value, adds a new node to the end of a list, creates a linked list for path directories, and finds the path of a file name.
exec_line.c Contains the functions of: splitting a string by converting it to an array, reallocating the block of memory, executing a command, and freeing the array of pointers
strings.c Contains the functions to: return a pointer in memory, concatenate three strings, write the character to standard output, count chars and print a string.

Modes

The user can have the experience in an interactive and non-interactive way.

To use the interactive mode use . Immediately the user will see a warning $ indicating that our shell is ready to read the command. And to exit the program, use the word exit. Example:

$ ./hsh
$ /bin/ls

En non-interactive mode the user will enter command line arguments,In non-interactive mode, you can pipe commands to the program using echo or cat:

Example:

$ echo "/bin/ls" | ./hsh
$ cat file_name | ./hsh

Bugs

No known bugs.

Authors

simple_shell's People

Contributors

maria-r16 avatar obedrav avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.