From 922db1e08f76510ab9b2b22aea2580d8c72f1a12 Mon Sep 17 00:00:00 2001 From: Camille Chauvet Date: Fri, 17 Feb 2023 18:28:06 +0100 Subject: [PATCH] fix: quote remover --- .minishell.h.swp | Bin 12288 -> 0 bytes test.sh | 155 --------------------------------------- utils/ft_quote_remover.c | 4 +- 3 files changed, 2 insertions(+), 157 deletions(-) delete mode 100644 .minishell.h.swp delete mode 100644 test.sh diff --git a/.minishell.h.swp b/.minishell.h.swp deleted file mode 100644 index 688eacd31229548560188416d8fedd2da2fa0736..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 12288 zcmeI2y>H}17{(_cK9(aK0xD?cvO>3Pa{HAaqD{o1yF^@+3!DVG6i8TJdz>A`v5h_6 zWch438bDNtKL8pEL~$UHprD}u#7Q(%RM#O2L<15P&vAWYUq zHJq?K`qfOZxzK6ua*s!S=DMS!M!$TVZq*KG2af1KESxio(`3HWZb_x;%qe>ReVa!V z)x)&|+5zo=c0fCz9ncPF2ebp)ft$$z5loTSknk;O($A**sfm4hs(0D}?SOVbJD?rV z4rm9o1KI)YfObGTpdHW-+=LF8HX)zfN(j9T$>ab3+28*kpCsgYFb%%EhmalcAoymQ zkbQ6({CGDZSHSBa0MCK5;9)Qgem_CTb?_bd47>;S!8UNfGB^pY-$lq(@CM*u9h?Dw zRtWhTybEHm1x|o(?VS58eiEf|tQAus{!NfOT*dv_TD=2GZLW(3^JPKX;(Y zJexa&yiySc^9D<#GVr-wsSivyX8G9;`#0jsuJJ!>D@&)$uHh1SiHKpqZ068Ngs~-P zBn?(h+omvKF84&G(q|#FeG8|;aCsyu^?Gt6O2*4!O2FE+F#sQAg$Osp?I=HE`^<`k z*>mOHOD^Eph98T<8TU%FgC-VSnNlU#vui3Fnq)Ia(M}!vktNcs(@R?`wBAfZnbr4e zs&|gcglHZ0s=!tB$w-nUTB&a{VeGJBtr%A5O6FWyr!>S6z5(HAlvkgbGNEL?R%C?D z+?qV2^&rVW^+bDSAe~RU>gF6(LG@lfI*T#pOQQ043-QVySqS%Rwx4C2mM$YE3o?4c zLeVIHj^@^;B`DDdqKO41Ba~xF@81o#LS_nfV+v``2l|}OPRuuas+TMlY4LIt>c+%a z^#(ljJr7^~VY(D<{DH#h#hpacaJcKTaCDa;4s(4k5@WM#G|2PAUDM?+Vvur4O+V!+ zL@})=MXfjtkzqDplLx3^tEy*IFGK<}jF^;)(u=s=gn%CPay(an_)n)DDiK=j87R^y6FNgR(1 zGYIfflPloZ0I5(Gz8CUjxja-bp0R&cj)tBv1-Fa=3%N6hO z8x7pE+}LJxSzbcUu4W%E13w%#`j3}(XK@q#k+8Wx**1)tdnOkX&5q>>ccLvqXoT!b zn&s;(8gHM81$U!n^1IQWDdaih@}491n`)=}(waBco?3h6!s^9~#syO44wg}e7Te@X zQa`p$E<+GJ#w`=v4Ddc?c9(Wqo%v>~(`-LR+l$@KLbtU@dqbLi-ke{$TCL(3zmpB$ zMW;QP;Q3?)FA6Tu_I!8Y(e8Y!RFGC@rDC>A<>-x-JPWb(2SPZ? zL;^F{6NRt7)!0O2wwoyxG_#Tm*ErmvR2wNG&s04V%)cXV^baRUX?M1(Lem4a%LEUr dG8WhEW|BCP8+wl /dev/null -cp ../minishell . -chmod 755 minishell - -function exec_test() -{ - TEST1=$(echo $@ "; exit" | ./minishell 2>&-) - ES_1=$? - TEST2=$(echo $@ "; exit" | bash 2>&-) - ES_2=$? - if [ "$TEST1" == "$TEST2" ] && [ "$ES_1" == "$ES_2" ]; then - printf " $BOLDGREEN%s$RESET" "✓ " - else - printf " $BOLDRED%s$RESET" "✗ " - fi - printf "$CYAN \"$@\" $RESET" - if [ "$TEST1" != "$TEST2" ]; then - echo - echo - printf $BOLDRED"Your output : \n%.20s\n$BOLDRED$TEST1\n%.20s$RESET\n" "-----------------------------------------" "-----------------------------------------" - printf $BOLDGREEN"Expected output : \n%.20s\n$BOLDGREEN$TEST2\n%.20s$RESET\n" "-----------------------------------------" "-----------------------------------------" - fi - if [ "$ES_1" != "$ES_2" ]; then - echo - echo - printf $BOLDRED"Your exit status : $BOLDRED$ES_1$RESET\n" - printf $BOLDGREEN"Expected exit status : $BOLDGREEN$ES_2$RESET\n" - fi - echo - sleep 0.1 -} - -printf "$BOLDMAGENTA __ __ _____ _ _ _____ _____ _ _ ______ _ _ \n" -printf "| \/ |_ _| \ | |_ _|/ ____| | | | ____| | | | \n" -printf "| \ / | | | | \| | | | | (___ | |__| | |__ | | | | \n" -printf "| |\/| | | | | . \` | | | \___ \| __ | __| | | | | \n" -printf "| | | |_| |_| |\ |_| |_ ____) | | | | |____| |____| |____ \n" -printf "|_| |_|_____|_| \_|_____|_____/|_| |_|______|______|______|\n$RESET" -echo - -# ECHO TESTS -exec_test 'echo test tout' -exec_test 'echo test tout' -exec_test 'echo -n test tout' -exec_test 'echo -n -n -n test tout' - - -# CD TESTS -exec_test 'cd .. ; pwd' -exec_test 'cd /Users ; pwd' -exec_test 'cd ; pwd' -exec_test 'mkdir test_dir ; cd test_dir ; rm -rf ../test_dir ; cd . ; pwd ; cd . ; pwd ; cd .. ; pwd' - - -# PIPE TESTS -exec_test 'cat tests/lorem.txt | grep arcu | cat -e' -exec_test 'echo test | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e | cat -e| cat -e| cat -e| cat -e| cat -e| cat -e| cat -e| cat -e| cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e|cat -e' -exec_test 'cat /dev/random | head -c 100 | wc -c' -exec_test 'ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|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ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls|ls' - -# ENV EXPANSIONS + ESCAPE -exec_test 'echo test \ test' -exec_test 'echo \"test' -exec_test 'echo $TEST' -exec_test 'echo "$TEST"' -exec_test "echo '$TEST'" -exec_test 'echo "$TEST$TEST$TEST"' -exec_test 'echo "$TEST$TEST=lol$TEST"' -exec_test 'echo " $TEST lol $TEST"' -exec_test 'echo $TEST$TEST$TEST' -exec_test 'echo $TEST$TEST=lol$TEST""lol' -exec_test 'echo $TEST lol $TEST' -exec_test 'echo test "" test "" test' -exec_test 'echo "\$TEST"' -exec_test 'echo "$=TEST"' -exec_test 'echo "$"' -exec_test 'echo "$?TEST"' -exec_test 'echo $TEST $TEST' -exec_test 'echo "$1TEST"' -exec_test 'echo "$T1TEST"' - -# ENV EXPANSIONS -ENV_SHOW="env | sort | grep -v SHLVL | grep -v _=" -EXPORT_SHOW="export | sort | grep -v SHLVL | grep -v _= | grep -v OLDPWD" -exec_test 'export =' -exec_test 'export 1TEST= ;' $ENV_SHOW -exec_test 'export TEST ;' $EXPORT_SHOW -exec_test 'export ""="" ; ' $ENV_SHOW -exec_test 'export TES=T="" ;' $ENV_SHOW -exec_test 'export TE+S=T="" ;' $ENV_SHOW -exec_test 'export TEST=LOL ; echo $TEST ;' $ENV_SHOW -exec_test 'export TEST=LOL ; echo $TEST$TEST$TEST=lol$TEST' -exec_test 'export TEST=LOL; export TEST+=LOL ; echo $TEST ;' $ENV_SHOW -exec_test $ENV_SHOW -exec_test $EXPORT_SHOW -exec_test 'export TEST="ls -l - a" ; echo $TEST ; $LS ; ' $ENV_SHOW - -# REDIRECTIONS -exec_test 'echo test > ls ; cat ls' -exec_test 'echo test > ls >> ls >> ls ; echo test >> ls; cat ls' -exec_test '> lol echo test lol; cat lol' -exec_test '>lol echo > test>lol>test>>lol>test mdr >lol test >test; cat test' -exec_test 'cat < ls' -exec_test 'cat < ls > ls' - -# MULTI TESTS -exec_test 'echo testing multi ; echo "test 1 ; | and 2" ; cat tests/lorem.txt | grep Lorem' - -# SYNTAX ERROR -exec_test ';; test' -exec_test '| test' -exec_test 'echo > <' -exec_test 'echo | |' -exec_test '<' - -# EXIT -exec_test "exit 42" -exec_test "exit 42 53 68" -exec_test "exit 259" -exec_test "exit 9223372036854775807" -exec_test "exit -9223372036854775808" -exec_test "exit 9223372036854775808" -exec_test "exit -9223372036854775810" -exec_test "exit -4" -exec_test "exit wrong" -exec_test "exit wrong_command" -exec_test "gdagadgag" -exec_test "ls -Z" -exec_test "cd gdhahahad" -exec_test "ls -la | wtf" - -rm lol ls test diff --git a/utils/ft_quote_remover.c b/utils/ft_quote_remover.c index 3fedb64..e8c1420 100644 --- a/utils/ft_quote_remover.c +++ b/utils/ft_quote_remover.c @@ -6,7 +6,7 @@ /* By: cchauvet