Coder Social home page Coder Social logo

minishell's Introduction

Hi ๐Ÿ‘‹, I'm Toni

A backend dev at mmmmake

Languages and Tools:

cplusplus c csharp dotnet git

toni-schmitt

ย toni-schmitt

minishell's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

tblaase

minishell's Issues

minishell prompt gets printed twice on ctrl c while a command is running

Describe the bug
When pressing CTRL+C while a command is running (like cat) minishell prompt gets printed twice.

To Reproduce
Steps to reproduce the behavior:

  1. Run a command waiting for input (like cat or wc)
  2. Press CTRL+C
  3. See error

Expected behavior
minishell prompt should get printed normally without double

Screenshots
image

Minishell trying to open wrong in file if heredoc is there

Describe the bug
When running cat << eof < file1 minishell trys to open eof thinking its a file.

To Reproduce
Steps to reproduce the behavior:

  1. Run cat << eof < file1
  2. See error

Expected behavior
eof should not be opened

Screenshots
minishell:
eof output is from a debug print added here:

if (fd == -1)
return (ft_perror(EXIT_FAILURE, "open error"));

image

image
bash:
image

Additional context
Also happens in these contexts:
image

Commands with \ will not work and get interpreted as syntax error

Describe the bug
Commands where a \ is included will get interpreted as syntax error due to

if (line[i] == ';' || line[i] == '\\')
and subject.pdf saying "Not interpret unclosed quotes or unspecified special characters like \ or ;.". Should this be considered syntax error or should this be interpreted as a string? Unclosed quotes and semicolons get interpreted as syntax error right now.

To Reproduce
Steps to reproduce the behavior:

  1. Run printf hi\n
  2. See syntax error

Screenshots
image

subshell not working correctly and leaking

Describe the bug
when running a command containing a subshell it creates a leak and cuts part of the subshell command

To Reproduce
Steps to reproduce the behavior:

  1. run echo hi && (echo this is subshell)
  2. See error

Expected behavior
don't cut the end of the command and don't leak

Screenshots
minishell:
grafik

Additional context
Added the traces of valgrind and tested running without valgrind lead to the same behavior.

ctrl+D/exit leaking 6 bytes

Describe the bug
using exit is leaking for 6 bytes

To Reproduce
Steps to reproduce the behavior:

  1. run valgrind --leak-check=full --track-origins=yes ./minishell
  2. run exit or press ctrl+D
  3. See error

Expected behavior
not leaking

Screenshots
Screen Shot 2021-12-16 at 4 58 02 PM

$VAR interpretation having problems interpreting non existant variables

Describe the bug
when using som $VAR stuff that is not existing in our minishell like $$ it is double freeing

To Reproduce
Steps to reproduce the behavior:

  1. run echo $$
  2. now broken ๐Ÿ˜ญ

Expected behavior
should just treat it as a string

Screenshots
grafik

Additional context
i found that the double free happens in interprete_env_var.c on line 96 in get_var

Piping does not work properly

Describe the bug
When piping between processes, not more than 64KiB can be sent over the pipe

To Reproduce
Steps to reproduce the behavior:

Execute dd if=/dev/urandom | pv | dd of=/dev/null
The program locks up because write call is blocking, when pressing CTRL+C to send a SIGINT the exit messages of dd and pv show that only 65536 bytes are sent. The problem is also reproducable without pv(pipe viewer) by just executing the 2 dd instances.

Expected behavior
The pipes writing to eachother without it blocking or getting limited to 64KiB

wildcard * is not working as intended

Describe the bug
Wildcard alsways is all stuff from directory

To Reproduce
Steps to reproduce the behavior:
look at what minishell does in screenshot and compare it to what bash does

Expected behavior
look st the screenshot

Screenshots
grafik

Additional context
Add any other context about the problem here.

[BUG] Parser creates empty tokens after subshell token

Describe the bug
Parser sometimes creates an empty token and passes it to expander after a subshell token.

Expected behavior
Token should not be empty and should be actual token

Screenshots
image

Additional context
Does not need fixing, just keep in mind when creating expander

combination of && and || does not work properly

Describe the bug
when running cat Makefile | grep PATH >file1 && cat <file1 && wc file1 && false && echo hi || cat <<eof the output of the last cat which should print the heredoc is not printed but it should

To Reproduce
Steps to reproduce the behavior:

  1. run cat Makefile | grep PATH >file1 && cat <file1 && wc file1 && false && echo hi || cat <<eof
  2. Compare output to bash
  3. See error

Expected behavior
The output from cat <<eof is not printed but should be printed, at least my bash prints it

Screenshots
grafik
after the red line there should be the output of the heredoc but it isn't

this is the output from my bash, ignore the can't overwrite file
grafik

Additional context
Add any other context about the problem here.

echo not working correctly when handed '\0'

Describe the bug
When giving input with double quotes text and double quotes text in the middle gets lost

To Reproduce
Steps to reproduce the behavior:

  1. Type into minishell: ""hi""
  2. See wrong output

Expected behavior
Output should be hi not empty
Hanlde quotes differently! Quote tokens should be split like this (considering input from above):
""
hi
""

Screenshots
image

wrong exit code on && combined with ||

Describe the bug
running echo hi && echo haha || echo hi2 results in exit_code beeing 1, should be 0 at least bash is 0

To Reproduce
Steps to reproduce the behavior:

  1. run echo hi && echo haha || echo hi2
  2. run echo $?
  3. See error

Expected behavior
exit code beeig 0

Screenshots
minishell:
grafik

bash:
grafik

runnning a cmd like cat without an argument

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. run cat
  2. press ctrl + C
  3. See error
  4. run echo $?
  5. See error

Expected behavior
just print a new prompt on a new line and set error code to 130

Screenshots
grafik
vs bash
grafik

not working when running correct path/cmd

Describe the bug
when running /bin/ls it doesn't work

To Reproduce
Steps to reproduce the behavior:

  1. run /bin/ls in minishell
  2. See error

Expected behavior
should just
Screen Shot 2021-12-14 at 12 30 14 PM
run the command if handed with the path

Screenshots
If applicable, add screenshots to help explain your problem.
Screen Shot 2021-12-14 at 12 29 16 PM

GitHub Actions failes when libft functions used

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Go to actions in the export branch
  2. See error

Expected behavior
No error.

Screenshots
Email from 27.10. 09:20pm

Additional context
Add any other context about the problem here.

all subshells fail to run and exit with invalid syntax

Describe the bug
all subshells i tested, even valid ones are not working

To Reproduce
Steps to reproduce the behavior:

  1. run any command containing a subshell
  2. See error

Expected behavior
run valid subshells

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
Add any other context about the problem here.

Subshell does not get splitted correctly

To Reproduce
Steps to reproduce the behavior:

  1. Execute echo "hi"&&(echo "this"is"such$PWD">file123&&false||(cat file123)&&false||true&&echo eos)&&cat file1
  2. See error

Expected behavior
subshell should be one token and after that && should be one token and not appendet to subshell

Screenshots
image

quotes not working 100%

Describe the bug
$VARS that should be interpreted are not interpreted
when the outside quotes are " $VARS are interpreted if outside quotes are ' they should just be treated as a string

To Reproduce
Steps to reproduce the behavior:

  1. run echo "'$USER'"
  2. See error

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
this is our minishell
grafik

this is bash
grafik

cmd after subshell gets lost

Describe the bug
running echo hi && (echo subshell | cat | cat) && echo hi2 never prints hi2
To Reproduce
Steps to reproduce the behavior:

  1. run echo hi && (echo subshell | cat | cat) && echo hi2
  2. See error

Expected behavior
print

hi
subshell
hi2

wrong exit code on && combined with ||

Describe the bug
running echo hi && echo haha || echo hi2 results in exit_code beeing 1, should be 0 at least bash is 0

To Reproduce
Steps to reproduce the behavior:

  1. run echo hi && echo haha || echo hi2
  2. run echo $?
  3. See error

Expected behavior
exit code beeig 0

Screenshots
minishell:
grafik

bash:
grafik

weird behaviour when giving empty quotes as argument

Describe the bug
can't debug this with macOS, when running empty quotes as an argument it prints Permission denied and exits with -1 but not while debugging on macOS.
So debug on Linux!!!

To Reproduce
Steps to reproduce the behavior:

  1. run "" or ''
  2. run echo $?
  3. See error

Expected behavior
should print command not found and exit with 127

Screenshots
minishell:
Screen Shot 2021-12-16 at 8 32 30 PM

bash:
Screen Shot 2021-12-16 at 8 32 55 PM

Additional context
debugging in Linux should give clarity what happens and why
if it doesn't, add a special case if (ft_strlen(cmd)==0) return (cmd_not_found)

only using a closing parenthesis causes infinite loop

Describe the bug
only using a closing parenthesis doesn't get detected as invalid syntax and causes an infinite loop

To Reproduce
Steps to reproduce the behavior:

  1. run echo hi && echo ciao)
  2. See error

Expected behavior
should be invalid syntax

Screenshots
grafik

running minishell inside minishell wrong exit

Describe the bug
when you run minishell inside minishell and execute a not existing cmd and exit the minishell, then check the exit status with echo $? it is 0 but should be 127

To Reproduce
Steps to reproduce the behavior:

  1. run minishell
  2. run haha
  3. run exit or ctrl+D
  4. run echo $?
  5. see Error

Expected behavior
exit status should be the last exit status, in this case 127

Screenshots
minishell:
Screen Shot 2021-12-16 at 8 48 20 PM

bash:
Screen Shot 2021-12-16 at 8 48 51 PM

Additional context
only happens if minishell is run inside minishell

all in and out redirections from outside the subshell are not working

Describe the bug
when running echo hi, this is a test | cat | (wc -c && ls -la && false || echo this is true) it seems to be stuck in a loop and when pressing ctrl+C it prints everything but in a weird way.

To Reproduce
Steps to reproduce the behavior:

  1. run echo hi, this is a test | cat | (wc -c && ls -la && false || echo this is true)
  2. Press ctrl+C
  3. ๐Ÿ˜ญ
  4. See error
  5. notice the mmiinniisshheell$$ prompt...

Expected behavior
should execute every command
output should be like this:
grafik

Screenshots
This is how it looks right now:
grafik

Additional context
Add any other context about the problem here.

echo * does segfault with valgrind

Describe the bug
running echo * with valgrind shows errors and just segfaults the minishell

To Reproduce
Steps to reproduce the behavior:

  1. run valgrind --leak-check=full --track-origins=yes ./minishell
  2. run echo *
  3. See error

Expected behavior
print all the folders and files from the current directory.

Screenshots
grafik
grafik
grafik

Additional context
Maybe @toni-schmitt you can find the mistake with the added traces of valgrind.

CTRL + [KEY] printing ^[KEY]

Describe the bug
When pressing CTRL + [KEY] minishell also prints ^[KEY]

To Reproduce
Steps to reproduce the behavior:

  1. Press CTRL + D (for example) while running minishell
  2. See error

Expected behavior
^[KEY] should not print

Screenshots
image

minishell segfaulting when doing weird stuff with $VARS

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. run export fun+exit
  2. run $fun
  3. See error segfault

Expected behavior
should treat the value in this case as command
Screen Shot 2021-12-14 at 4 27 46 PM

Screenshots
here is our segfault
Screen Shot 2021-12-14 at 4 28 19 PM

minishell thinking `ft_strlen(lex_tok)` is a subshell for some reason

Describe the bug
minishell thinking ft_strlen(lex_tok) is a subshell for some reason
while debugging i noticed it goes into the expander and from there into the subshell function

To Reproduce
Steps to reproduce the behavior:

  1. run ft_strlen(lex_tok)
  2. See error

Expected behavior
syntax error

Screenshots
however this happens, it should not get past syntax check
Screen Shot 2021-12-16 at 10 36 47 PM

minishell exiting itself

Describe the bug
after executing it exits itself with printing exit

To Reproduce
Steps to reproduce the behavior:

  1. run abc | echo hi >file2 | wc
  2. See error

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
grafik

Additional context
Add any other context about the problem here.

double free and abort

Describe the bug
when first running print and then running print("hi") minishell aborts with a double free, check traces in screenshot

To Reproduce
Steps to reproduce the behavior:

  1. run print
  2. run print("hi")
  3. See error

Expected behavior
only printing invalid syntax and then returning to prompt

Screenshots
minishell:
grafik

bash:
grafik

Additional context
traces from valgrind:
grafik
grafik

all traces point to sth in lexer and exit_on_syntax_error

detecting subshell and trying to run it even if it is input error

Describe the bug
if you run echo test (cat |wc) it detects a subshell

To Reproduce
Steps to reproduce the behavior:

  1. enable prnt_tokens in parser
  2. run echo test (cat |wc)
  3. See error

Expected behavior
input error

Screenshots
this is output now (subshell not working right now)
Screen Shot 2021-12-13 at 2 49 03 PM

this should be the output
Screen Shot 2021-12-13 at 2 57 46 PM

Additional context
problem seems to be in parser

segfaulting when running only subshell

Describe the bug
when running nothing but a subshell it segfaults in is_valid_syntax !is_special line 116 of check syntax

To Reproduce
Steps to reproduce the behavior:

  1. run `(echo hi | wc)
  2. See error

Expected behavior
just run the command

Screenshots
here is the position of the callstack where it is failing
Screen Shot 2021-12-14 at 12 58 25 PM

here is the segfault
Screen Shot 2021-12-14 at 1 01 39 PM

bug found with echo

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Run echo "-n Hello this is a test if echo is leaking"
  2. there is no output printed

Expected behavior
output should look like -n Hello this is a test if echo is leaking

probably there is more errors with ' and " than just this one

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.