Skip to content

minishell project @ 42 Amsterdam (Codam Coding College). This repository contains a shell built from scratch in C. The syntax and features are based on Bash. Built in collaboration with @Jackdehaan at Codam

Notifications You must be signed in to change notification settings

rubenfin/minishell

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

minishell

42 school project


Introduction

This project is a core part of the 42 school curriculum. The goal of minishell is to create a simple, functional shell, similar to bash or zsh. This project teaches fundamental concepts of process management, command execution, and environment handling.

The shell should be able to:

  • Display a prompt and wait for user input.
  • Execute external commands and programs.
  • Handle a variety of built-in commands.
  • Manage environment variables.
  • Support command redirection (<, >).
  • Support command pipes (|).

How It Works

The minishell program operates in a continuous loop:

  1. Read: The program reads a command line entered by the user from standard input.
  2. Parse: The command line is tokenized and parsed into a command and its arguments. This stage handles special characters like pipes, redirections, and quotes.
  3. Execute: Based on the parsed command, the program takes action:
    • If the command is a built-in (e.g., cd, echo, export), the shell's own functions are called.
    • If it's an external command, the shell forks a new process, and the child process uses execve to execute the command. The parent process waits for the child to finish.
  4. Loop: After the command is executed, the program frees all allocated memory and returns to the read stage, displaying the prompt again.

Built-in Commands

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

Installation and Usage

To compile and run minishell, you will need a Makefile.

Compilation

You can compile your program using the provided Makefile.

make

Running the Program

Once compiled, you can run the executable from your terminal.

./minishell

Example Usage

$ ls -l
$ echo "Hello, World!" > file.txt
$ cat file.txt
$ env | grep PATH

Project Contributor


About

minishell project @ 42 Amsterdam (Codam Coding College). This repository contains a shell built from scratch in C. The syntax and features are based on Bash. Built in collaboration with @Jackdehaan at Codam

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •