Coder Social home page Coder Social logo

yaten / 42-minishell Goto Github PK

View Code? Open in Web Editor NEW

This project forked from willianlim/minishell

0.0 0.0 0.0 580 KB

๐Ÿš The objective of this project is to create a simple shell in C.

License: GNU General Public License v3.0

C 97.29% Makefile 2.71%

42-minishell's Introduction

image

About Minishell

This is the eighth project in the 42 Cadet Curriculum. Minishell is about creating a simple shell with limited external functions.

As beautiful as a shell.

External functs.

readline, rl_clear_history, rl_on_new_line, rl_replace_line, rl_redisplay, add_history, printf, malloc, free, write, access, open, read, close, fork, wait, waitpid, wait3, wait4, signal, sigaction, sigemptyset, sigaddset, kill, exit, getcwd, chdir, stat, lstat, fstat, unlink, execve, dup, dup2, pipe, opendir, readdir, closedir, strerror, perror, isatty, ttyname, ttyslot, ioctl, getenv, tcsetattr, tcgetattr, tgetent, tgetflag, tgetnum, tgetstr, tgoto, tputs

Group

Made with <3 by:

  • Willian Lima (@willianlim)
  • Paulo Rafael Ramalho (@Yaten)

Installation & Usage

Requirements

The only requirements are:

  • GNU make (v4.2.1)
  • GCC (v9.4.0)

Those versions are the ones used during development.

Building the program

  1. Download/Clone this repo

     git clone https://github.com/willianlim/Minishell
    
  2. cd into the root directory and run make

     cd Minishell
     make
    

Running the program

  1. After building the source, run ./bin/minishell from the project root.

     ./bin/minishell
    

Mandatory part

  • Display a prompt when waiting for a new command.
  • History.
  • Search and launch the right executable.
  • Only one global variable.
  • Not interpret unclosed quotes or special characters which are not required by the subject.
  • Handle โ€™ (single quote) which should prevent the shell from interpreting the metacharacters in the quoted sequence.
  • Handle " (double quote) which should prevent the shell from interpreting the metacharacters in the quoted sequence except for $ (dollar sign).
  • Handle environment variables ($ followed by a sequence of characters) which should expand to their values.
  • Handle $? which should expand to the exit status of the most recently executed foreground pipeline.
  • Handle ctrl-C, ctrl-D and ctrl-\ which should behave like in bash.

In interactive mode:

  • ctrl-C displays a new prompt on a new line.
  • ctrl-D exits the shell.
  • ctrl-\ does nothing.

Implemented builtins

  • echo with option -n
  • cd with only a relative or absolute path
  • pwd with no options
  • export with no options
  • unset with no options
  • env with no options or arguments
  • exit with no options

Implemented redirections

  • < redirect input.
  • > redirect output.
  • << with a delimiter, then read the input until a line containing the delimiter is seen.
  • >> redirect output in append mode.
  • Pipes (| character). The output of each command in the pipeline is connected to the input of the next command via a pipe.

Yes, my own little bash! :D


Reference

  • links

42-minishell's People

Contributors

blackwol avatar rogerioprogramador avatar willianlim avatar yaten 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.