Skip to content

Minishell is a 42 project that impliments a mini functioning shell in C.

Notifications You must be signed in to change notification settings

Oumaimafisaoui/Minishell-Final

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Minishell

This project is a working implemetation of a mini shell:

This shell does:

• Display a prompt when waiting for a new command.
• Have a working history.
• Search and launch the right executable (based on the PATH variable or using a relative or an absolute path).
• Not use more than one global variable. Think about it. You will have to explain its purpose.
• Not interpret unclosed quotes or special characters which are not required by the subject such as \ (backslash) or ; (semicolon).
• 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).

Implement redirections:

◦ < should redirect input.
◦ > should redirect output.
◦ << should be given a delimiter, then read the input until a line containing the delimiter is seen. However, it doesn’t have to update the history!
◦ >> should redirect output in append mode.
• Implement pipes (| character). The output of each command in the pipeline is connected to the input of the next command via a pipe.
• 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.

• Your shell must implement the following 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

My tests:
  • echo $HIT $PATH
  • echo -nnnnnnn / -n -n -n -n /
  • echo $?
  • exit jkfjrwnwlrlner / exit jkwfnrwnlw 97 / exit kk;rwf kfjrkrw / exit 7865 9558859
  • ls<< lo>>file1 >> file2 | ls -la << po
  • export ggg======tt
  • env -i ./minishell
  • minishell inside minishell signals
  • long line
  • unset PATH and inputting env and export
  • echo ""
  • echo "\0"
  • cd with deleted directory
  • >cat me >| me
# Project steps:
- [X] Read all ressources - [X] Create prompt handeler - [X] handle signals - [X] handle tokens - [X] handle syntax error - [X] Parsing - [X] Execution

This project needs the following dependencies installed to run:

https://github.com/paji1/valgrind_for_new_infra

All the project ressources are documented in Miro :

https://miro.com/app/board/uXjVO3ccsYw=/?share_link_id=561717126947

Screen Shot 2022-07-03 at 8 55 08 PM

About

Minishell is a 42 project that impliments a mini functioning shell in C.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published