Closed axellee1994 closed 4 months ago
Need to enter into EDIT to see all of the full testcases. \ is being hidden atm
@gysiang If you are free, can please try to solve some of these test cases?
I need to refactor a few more codes like builtin_export, unset etc.
Went into redirection instead of just printing out as string literal
minishell$ echo "$PWD" in parse double quotes token: echo token type: 0 token: /home/gyong-si/Documents/42/minishell token type: 0 /home/gyong-si/Documents/42/minishell minishell$
Its working in the new pull request, the flag i put in was refactored into a wrong place. I'll work on cleaning up my code and checking through the eval requirements. Can you finish the rest of the echo test cases?
minishell$ echo "$PWD"
in parse double quotes
token: echo
token type: 0
token: /home/gyong-si/Documents/42/minishell
token type: 0
/home/gyong-si/Documents/42/minishell
minishell$
Its working in the new pull request, the flag i put in was refactored into a wrong place. I'll work on cleaning up my code and checking through the eval requirements. Can you finish the rest of the echo test cases?
Yeah I am still working on it, like the echo$TEST$TEST etc.
echo "$TEST" Output: "\TEST" Correct Output: $TEST
Is this test case correct? @axellee1994 I stop working on these echo two people changing the code makes it harder to work on it.
I already screenshot the what the correct output needed to be.
GitHub won't let me display that backslash.
@gysiang , can you help me to double check how does echo $PWD etc. is able to get their environment value?
The reason is because in the handle_env_variable, if the environment variable does not exists, it will display an empty string. So commands like echo "$TEST$TEST=lol" will result in =lol.
But when echo $TEST, it will still display as $TEST
@gysiang found the issue for echo $?HELLO.
It is the custom realloc issue that was corrupting it.
@gysiang , can you help me to double check how does echo $PWD etc. is able to get their environment value?
The reason is because in the handle_env_variable, if the environment variable does not exists, it will display an empty string. So commands like echo "$TEST$TEST=lol" will result in =lol.
But when echo $TEST, it will still display as $TEST
I think this is because of another test case. I tweaked the parser for it to add back the $ into the token. Now when i try this in bash, it should return just a space or null when it cannot find the variable in env.
echo "$TEST" Output: "\TEST" Correct Output: $TEST
void handle_variable_not_found(char **result, t_shell *minishell, const char *var_name)
{
char *temp;
temp = prepend_dollar(var_name);
append_to_result(result, minishell, temp);
free(temp);
}
@gysiang , can you help me to double check how does echo $PWD etc. is able to get their environment value? The reason is because in the handle_env_variable, if the environment variable does not exists, it will display an empty string. So commands like echo "$TEST$TEST=lol" will result in =lol. But when echo $TEST, it will still display as $TEST
I think this is because of another test case. I tweaked the parser for it to add back the $ into the token. Now when i try this in bash, it should return just a space or null when it cannot find the variable in env.
echo "$TEST" Output: "\TEST" Correct Output: $TEST
void handle_variable_not_found(char **result, t_shell *minishell, const char *var_name) { char *temp; temp = prepend_dollar(var_name); append_to_result(result, minishell, temp); free(temp); }
Okay can thanks, I will check this on my side now.
@gysiang , can you help me to double check how does echo $PWD etc. is able to get their environment value? The reason is because in the handle_env_variable, if the environment variable does not exists, it will display an empty string. So commands like echo "$TEST$TEST=lol" will result in =lol. But when echo $TEST, it will still display as $TEST
I think this is because of another test case. I tweaked the parser for it to add back the $ into the token. Now when i try this in bash, it should return just a space or null when it cannot find the variable in env.
echo "$TEST" Output: "\TEST" Correct Output: $TEST
void handle_variable_not_found(char **result, t_shell *minishell, const char *var_name) { char *temp; temp = prepend_dollar(var_name); append_to_result(result, minishell, temp); free(temp); }
For this particular testcase, because there is a backslash, it is supposed to treat everything behind it as a string literal, meaning that echo "'backslash$TEST" is supposed to be treated as echo '$TEST'.
@gysiang Ivan, please today take a break . I am checking on my side for the codes and resolving the issues. Thanks 🙏
[x] Testcase: echo hello world Our Output: hello world Bash Output: hello world
[x] Testcase: echo "hello world" Our Output: hello world Bash Output: hello world
[x] Testcase: echo 'hello world' Our Output: hello world Bash Output: hello world
[x] Testcase: echo hello"world" Our Output: hello'world' (UNABLE TO SOLVE ->MOVING ONTO NEXT QUESTION 06/06/24 @ 6.35PM) Bash Output: helloworld
[x] Testcase: echo hello'world' Our Output: hello'world' (UNABLE TO SOLVE ->MOVING ONTO NEXT QUESTION 06/06/24 @ 6.35PM) Bash Output: helloworld
[x] Testcase: echo hello""world Our Output: helloworld (UNABLE TO SOLVE ->MOVING ONTO NEXT QUESTION 06/06/24 @ 6.35PM) Bash Output: helloworld
[x] Testcase: echo hello''world Our Output: helloworld (UNABLE TO SOLVE ->MOVING ONTO NEXT QUESTION 06/06/24 @ 6.35PM) Bash Output: helloworld
[x] Testcase: echo '' (Single Quotes) Our Output: Bash Output:
[x] Testcase: echo "$PWD" Our Output: /home/axlee/Desktop/42Cursus/minishell Bash Output: /home/axlee/Desktop/42Cursus/minishell
[x] Testcase: echo '$PWD' Our Output: /home/axlee/Desktop/42Cursus/minishell Bash Output: $PWD
[x] Testcase : echo "aspas ->'" Our output: aspas ->"$ Bash Output: aspas ->'$
[x] Testcase: echo "aspas -> ' " Our output: aspas ->$ Bash Output: aspas -> ' $
[x] Testcase: echo 'aspas ->"' Our output: aspas ->" Bash Output: aspas ->"
[x] Testcase: echo 'aspas -> " ' Our output: aspas -> " Bash Output: aspas -> "
[x] Testcase: echo "> >> < ? [ ] | ; [ ] || && ( ) & # $ \ <<" Our output: > >> < ? [ ] (Issue is ; is not being recognised in the outer quotes) Bash Output: > >> < * ? [ ] | ; [ ] || && ( ) & # $ \ <<
[x] Testcase: echo '> >> < ? [ ] | ; [ ] || && ( ) & # $ \ <<' Our output: > >> < ? [ ] (Issue is ; is not being recognised in the outer quotes) Bash Output: > >> < * ? [ ] | ; [ ] || && ( ) & # $ \ <<
[x] Testcase: echo "exit_code ->$? user ->$USER home -> $HOME" Our output: exit_code ->$? user ->$USER home -> $HOME Bash Output: exit_code ->0 user ->axlee home -> /home/axlee
[x] Testcase: echo 'exit_code ->$? user ->$USER home -> $HOME' Our output: exit_code ->$? user ->$USER home -> $HOME Bash Output: exit_code ->$? user ->$USER home -> $HOME
[x] Testcase: echo "$" Our output: $ Bash Output: $
[x] Testcase: echo '$' Our output: $ Bash Output: $
[x] Testcase: echo $ Our output: Bash Output: $
[x] Testcase: echo $? Our output: Does not initialize when started, only works after executing another successful command Bash Output: 0
[x] Testcase: echo $?HELLO Our output: Bash Output: 0HELLO
[x] Testcase: echo -n hello Our output: -n hello Bash Output: helloaxlee@axlee:~/Desktop/42Cursus/minishell$
[x] Testcase: cd src -> echo $PWD $OLDPWD Our output: /h Bash Output: /home/axlee/Desktop/42Cursus/minishell/src /home/axlee/Desktop/42Cursus/minishell
[x] Testcase: echo "hi" | cat | cat | cat | cat | cat | cat | cat Our output: hi -> But has zombie process Bash Output: hi -> No Zombie Process
[x] Testcase: echo - "" " " hello minishell$ echo - "" " " hello in parse double quotes in parse double quotes
[x] echo test \ test Output: test test Correct Output: test test
[x] echo \"test minishell$ echo \"test
minishell$ exit exit axlee@axlee:~/Desktop/42_minishell$ echo \"test "test
[x] echo "$TEST$TEST=lol$TEST" Output: $TEST$TEST=lol$TEST Correct Output: =lol
[x] echo " $TEST lol $TEST" Output: $TEST lol $TEST Bash Output: lol
[ ] echo $TEST$TEST=lol$TEST""lol Output:$TEST $TEST =lol$TESTlol Correct Output: =lollol
[x] echo test "" test "" test Output: test test test Correct Output: test test test
[x] echo "backslash$TEST" Output: "backslashTEST" Correct Output: $TEST
[x] echo "$=TEST" Output: Correct Output: $=TEST
[x] echo "$?TEST" Output: 0TEST Correct Output:** 0TEST
[x] echo "$1TEST" Output: $1TEST Correct Output: TEST
[x] echo '' test (single quote) Output: test Correct Output: test
[x] echo "hello , $USER" | grep hello > output.txt Output: Correct Output: hello, axlee