Giter Site home page Giter Site logo

holbertonschool-simple_shell's Introduction

Readme for the simple shell project

Simple Shell

A super simple shell program written in C that allows users to input commands and executes them. This shell is designed to be a basic interactive command-line interface.


REQUIREMENTS :

  • Allowed editors: vi, vim, emacs
  • Compilation on Ubuntu 20.4 LTS
  • All files should end with a new line
  • All files should follow the Betty style
  • No memory leaks
  • No more than 5 functions per file
  • The header file should be include guarded
  • Use system calls only when needed

Compilation Command :

To compile the project, your code will be compiled this way : gcc -Wall -Werror -Wextra -pedantic -std=gnu89 *.c -o shell


Structure and Organization

Function Limit: Keep each file concise with ... functions. Header Inclusion: Feature all function prototypes in main.h and include guards to avoid repetition. Side Note: No more than 3 malloc function provided for this project.


Copy code

./shell The shell will display a prompt ($) where you can enter commands. It supports basic interactive command-line operations, handle the PATH and should be able to leave the function with exit.


Features

  • User-friendly prompt when running interactively.
  • Handles commands entered by the user.
  • Uses the getline function to read user input.
  • Basic error handling and debugging information

Commands

The shell supports executing various commands available on the system. Enter a command and press Enter to execute it. Exit To exit the shell, use the Ctrl + D keyboard shortcut or enter the exit command. Debugging The program includes debugging information that can be enabled or disabled by modifying the print_debug function calls in the code.


Documentation

Readability: Create a comprehensive README.md as the project's guide. Main Files: Use provided main.c files for testing but avoid including them in your final submission.


Example of shell function

root@50c158e79d1b:~/holbertonschool-simple_shell# ./shell
$ ls
README.md  execve.c             main.h    print_debug.c  read_command.c  shell.c
_getenv.c  find_file_in_path.c  man_page  printenv.c     shell           tokenize_command.c
$ ls - a
ls: cannot access '-': No such file or directory
ls: cannot access 'a': No such file or directory
$ ls -a
.     README.md  find_file_in_path.c  print_debug.c   shell
..    _getenv.c  main.h               printenv.c      shell.c
.git  execve.c   man_page             read_command.c  tokenize_command.c
$ ls                      -a
.     README.md  find_file_in_path.c  print_debug.c   shell
..    _getenv.c  main.h               printenv.c      shell.c
.git  execve.c   man_page             read_command.c  tokenize_command.c
$ env
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
OLDPWD=/root
_=./shell
$ pwd
/root/holbertonschool-simple_shell
$ exit
root@50c158e79d1b:~/holbertonschool-simple_shell#

Testing

valgrind --leak-check=full ./shell
echo "/bin/ls" | valgrind --leak-check=full ./shell
echo "                                                       " | valgrind --leak-check=full --show-leak-kinds=all ./shell
echo "/bin/ls -l -a" | valgrind --leak-check=full ./shell

Man page

Refer to the man page for detailed information on how to use the shell function

man ./man_page

Files

File Description
read_command.c Reads a line from the standard input and returns the input
_getenv.c Replicates the getenv function to be called in the find_file_in_path function
tokenize_command.c Tokenize a command line and returns an array of strings
find_file_in_path.c Looks for files in the PATH environment variable
execve.c Calls the two previous functions in order to execute a command
print_debug.c Handles error conditions
shell.c Main function meant to replicate a simple shell
main.h The header file that contains all the functions prototypes

Authors : Simple Shell by Gilles and Benjamin

holbertonschool-simple_shell's People

Contributors

gillesr76 avatar benjaminparentt avatar

Stargazers

 avatar Teddy.D 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.