Giter Site home page Giter Site logo

batusengezer / minishell Goto Github PK

View Code? Open in Web Editor NEW

This project forked from 552020/minishell

0.0 0.0 0.0 4.49 MB

A minimalist shell implementation in C, as part of the school 42's core curriculum. Documented by Stefano Lombardo

Shell 0.01% C 97.45% Makefile 2.53%

minishell's Introduction

Minishell

A 'simple' Unix shell in C for the School 42 curriculum.

Table of Contents

Introduction

Minishell is a simple Unix shell developed in C as part of the School 42 curriculum. It is a collaborative project developed by Batu and Stefano. The program is being developed with certain constraints: - the strictly adherence to the so called Norm, which imposes certain (at times questionable) limitations such as a maximum function length of 25 lines, the prohibition of for-loops, and more, a restricted set of allowed functions.

Features

  • Display a prompt when waiting for a new command.
  • Working history.
  • Input redirection (<) and output redirection (> & >>)
  • Handling of environment variables (like $PATH)
  • Signal management for ctrl-C, ctrl-D and ctrl-\
  • Built-in commands support (echo, cd, pwd, export, unset, exit, pwd)
  • Quotation handling for both single (') and double (") quotes
  • Piping between commands using |
  • Expansion for $? to show exit status of the last executed command
  • ...

Installation & Usage

  • Clone the repository to your local machine: git clone https://github.com/552020/minishell.git
  • Navigate to the relevant directory cd minishell
  • Compile the project with make
  • Run minishell: ./minishell

Once Minishell is started, you can interact with it like any traditional Unix shell. Enter commands, use redirections (<, >, >>), and pipe commands.

Constraints

Allowed Functions

For the development of Minishell, we were restricted to using a specific set of functions. The permitted external functions are:

  • I/O Functions: readline, rl_clear_history, rl_on_new_line, rl_replace_line, rl_redisplay, add_history, printf, write, read, open, close
  • Memory Management: malloc, free
  • Process Management: fork, wait, waitpid, wait3, wait4, exit, execve
  • Signal Handling: signal, sigaction, sigemptyset, sigaddset, kill
  • File and Directory Handling: access, getcwd, chdir, stat, lstat, fstat, unlink, dup, dup2, pipe, opendir, readdir, closedir
  • Error Handling: strerror, perror
  • Terminal Control: isatty, ttyname, ttyslot, ioctl, getenv, tcsetattr, tcgetattr, tgetent, tgetflag, tgetnum, tgetstr, tgoto, tputs

In addition to the aforementioned functions, we were permitted to use our self-coded libft library. This library, a previous project from the School 42 curriculum, contains a set of 40 functions that serve as replacements for common C library functions like strcpy, calloc, and so on.

The Norm

The most notable restrictions of the norm are:

  • the 42 header should be present in every file
  • functions must not exceed 25 lines
  • global variables are generally not allowed
  • the use of ceratin keywords as for, do...while, switch, case, and goto.
  • Comments are not permitted within functions​​.
  • Blank spaces within a function are not allowed, except between variable declarations and the rest of the code​​.
  • All variables must be declared and set at the top of the function​​.

The entire set of rules and guidelines established by the Norm can be found in the document en.norm.pdf within the repository.

Architecture

minishell's People

Contributors

552020 avatar batusengezer 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.