Skip to content

hweeeez/minishell

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

minishell 🐚

2024

#valgrind --suppressions=readline.supp --leak-check=full --track-fds=yes --show-leak-kinds=all ./minishell

#valgrind --track-origins=yes --suppressions=../readline.supp --leak-check=full --show-leak-kinds=all --track-fds=yes ./minishell

#export a=1 b=2 f="file1 file2" s=" " n="" ls=" ls -l " e="echo '$0'" e=e c=c h=h o=o PWD="PIKACHU"

#sigint(ctrl c) and sigquit(ctrl ) - ignore sigquit, sigint use readline function #read, tokenize, ast nodes, parse, expansion, execute

File Structure

                  β–‘β–ˆβ–‘β–‘β–‘β–ˆβ–‘β–ˆβ–€β–€β–‘β–ˆβ–€β–€β–„β–‘β–ˆβ–€β–€β–‘β–ˆβ–€β–€β–‘β–ˆβ–€β–„β–‘β–€β–ˆβ–€β–‘β–ˆβ–‘β–‘β–‘β–‘β–ˆβ–€β–€β–‘β–ˆβ–€β–€β–„β–‘β–ˆβ–€β–€β–„β–‘β–„β–€β–€β–„β–‘β–ˆβ–‘β–‘β–ˆ
                  β–‘β–€β–„β–ˆβ–„β–€β–‘β–ˆβ–€β–€β–‘β–ˆβ–‘β–’β–ˆβ–‘β–ˆβ–€β–€β–‘β–ˆβ–€β–€β–‘β–ˆβ–‘β–ˆβ–‘β–‘β–ˆβ–‘β–‘β–ˆβ–€β–€β–ˆβ–‘β–ˆβ–€β–€β–‘β–ˆβ–„β–„β–€β–‘β–ˆβ–„β–„β–ˆβ–‘β–ˆβ–„β–„β–ˆβ–‘β–ˆβ–„β–„β–ˆ
                  β–‘β–‘β–€β–‘β–€β–‘β–‘β–€β–€β–€β–‘β–€β–‘β–‘β–€β–‘β–€β–€β–€β–‘β–€β–€β–€β–‘β–€β–€β–‘β–‘β–‘β–€β–‘β–‘β–€β–‘β–‘β–€β–‘β–€β–€β–€β–‘β–€β–‘β–€β–€β–‘β–€β–‘β–‘β–€β–‘β–ˆβ–‘β–‘β–‘β–‘β–„β–„β–„β–€
minishell
β”œβ”€β”€ inc/
β”‚   β”œβ”€β”€ minishell.h
β”‚   β”œβ”€β”€ token.h
β”‚   β”œβ”€β”€ parse.h
β”‚   β”œβ”€β”€ exec.h
β”‚   β”œβ”€β”€ pipe.h
β”‚   β”œβ”€β”€ redirect.h
β”‚   β”œβ”€β”€ builtins.h
β”‚   β”œβ”€β”€ heredoc.h
β”‚   β”œβ”€β”€ sig_control.h
β”‚   └── error.h
β”‚   └── env.h
β”‚   └── expansion.h
β”œβ”€β”€ libft/
β”œβ”€β”€ token/
β”œβ”€β”€ parse/
β”œβ”€β”€ exec/
β”œβ”€β”€ pipe/
β”œβ”€β”€ redirect/
β”œβ”€β”€ builtins/
β”œβ”€β”€ heredoc/
β”œβ”€β”€ signal/
β”œβ”€β”€ error/
β”œβ”€β”€ env/
β”œβ”€β”€ expansion/
β”œβ”€β”€ main.c
└── Makefile

Minishell Project Tasks 🐚

Current Development Tasks

1. Signal Handling

  • Fix SIGINT (Ctrl+C) exit status to return 130
  • Review and fix signal handling in heredoc context
  • ctrl-D (EOF) prints exit
  • ctrl-D (EOF) Invalid read of size 8 at 0x10B8A5: freetree (treehelper.c:25)

2. Variable Expansion & Word Splitting

  • Fix word splitting for variables
    # Issue example:
    export name="ninja          turtle"
    echo $name     # Should output: ninja turtle
    echo "$name"   # Should preserve original spacing
  • Preserve spaces in quoted variable expansions
  • "" and '' are tokens when sandwish by spaces, or end of input

3. File Operations & Permissions

  • Implement proper handling for non-executable files
  • Invalid cmd calls exit (and prints exit)
  • Add validation for . and .. directory execution attempts

4. Heredoc

  • Implement heredoc expansion
  • Implement heredoc delimiter with ''
  • Implement heredoc delimiter with no expansion

5. Redirections & Pipes

  • Fix pipe closing issues in redirect operations:
    # Test cases:
    > test
    >> test
  • Implement correct behavior for multiple heredocs
  • Fix heredoc behavior in pipe sequences
  • Handle multiple redirections:
    # Test case:
    cat < makefile < asd
  • Ensure pipe sequence continues with invalid commands:
    # Should continue execution despite 'blah' failing
    sleep 5 | blah | ls

6. Memory Management

  • Implement cleanup() functions for all components

7. Additional Tasks

  • Add/check error messages for failure cases if (input != NULL && ft_strcmp(input, "$?") == 1) { printf("%d\n", (*shell)->exit_status); add_history(input); free(input); continue; }

Testing Requirements

Signal Tests

# Test cases
ctrl+C during command execution
ctrl+C during heredoc
ctrl+C in empty prompt

Variable Expansion Tests

# Test cases
export var="a   b   c"
echo $var
echo "$var"
echo '$var'

Redirection Tests

# Test cases
cmd > file1 > file2
cmd >> file1 >> file2
cat < file1 < file2

Pipe Tests

# Test cases
cmd1 | cmd2 | invalid_cmd | cmd3
cmd1 | cmd2 > file | cmd3

Progress Tracking

  • Keep this README updated as tasks are completed
  • Mark completed tasks with [x]
  • Add new edge cases as discovered

Guidelines

  1. Test before marking tasks as complete
  2. Update behavior changes
  3. Add anything missing to this doc.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •