Skip to content

Marcel-git666/minishell

Repository files navigation

Minishell

A simple shell implementation as part of the 42 curriculum.

Project Overview

Minishell is a simplified version of a shell (command-line interpreter) that implements basic shell functionality:

  • Command execution
  • Built-in commands
  • Environment variable expansion
  • Redirections and pipes
  • Signal handling

Team Members

  • Marcel - Lexer, parser, memory management
  • Lada - Command execution, built-ins, environment handling

Current Status

  • Lexical analysis (tokenization)
  • Memory management
  • Command execution
  • Built-in commands
  • Redirections
  • Pipes
  • Environment variables
  • Signal handling

Memory Management Notes

Valgrind Suppression

The project uses a Valgrind suppression file to ignore "still reachable" memory associated with the readline library. According to the subject requirements, we are not required to fix readline memory leaks.

Known "Still Reachable" Memory

There is a 5-byte "still reachable" memory block from a static variable last_executed in the handle_input function (shell_loop.c). This is not a true leak as it's intentionally kept alive for the duration of the program to track command history behavior, and will be reclaimed by the OS at program termination.

Roadmap

Marcel's Tasks

  1. Complete Lexical Analysis

    • Basic tokenization
    • Handle quotes (single and double)
    • Extract environment variables
    • Fix memory leaks in token parsing
  2. Parser Implementation

    • Create abstract syntax tree (AST)
    • Handle command separation
    • Implement syntax validation
  3. Error Handling

    • Implement error messages
    • Add syntax error detection
    • Create graceful error recovery
  4. History Management

    • Implement command history
    • Handle history file operations
  5. Signal Handling Support

    • Set up signal handlers
    • Implement behavior for Ctrl+C, Ctrl+D, Ctrl+\
  6. Environment Variable Management

    • Environment variable storage
    • Variable expansion
    • Handle $? special variable

Lada's Tasks

  1. Command Execution

    • Implement path resolution
    • Handle command execution (execve)
    • Manage process forking
  2. Built-in Commands

    • echo with -n option
    • cd with relative/absolute paths
    • pwd
    • export
    • unset
    • env
    • exit
  3. Redirection Implementation

    • Input redirection (<)
    • Output redirection (>)
    • Append output (>>)
    • Heredoc (<<)
  4. Pipes

    • Implement pipe functionality
    • Handle multiple pipes

How to Run

Normal Mode

./run-minishell.sh normal

Valgrind Mode (For Memory Checking)

./run-minishell.sh valgrind

Valgrind with Readline Suppression

./run-minishell.sh suppressed

Useful Resources

About

42 School minishell project

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors