From 49ca6fed0a848627729afb7eccd8dc5ae91640cc Mon Sep 17 00:00:00 2001 From: Hugo LAMY Date: Tue, 21 Dec 2021 12:58:21 +0100 Subject: [PATCH] resoud false positif dans expansions et redirections --- tests/defaults/expansions.sh | 30 +++------------- tests/defaults/redirections.sh | 31 ---------------- tests/false_positive.sh | 64 ++++++++++++++++++++++++++++++++++ 3 files changed, 69 insertions(+), 56 deletions(-) diff --git a/tests/defaults/expansions.sh b/tests/defaults/expansions.sh index e2111b7..8fa16b5 100644 --- a/tests/defaults/expansions.sh +++ b/tests/defaults/expansions.sh @@ -263,10 +263,11 @@ echo “$rewtwet” echo '\$' +export HELLO=hello +echo $HELLO -export HELLO=hello; echo $HELLO - -export HELLO=hello; echo $hello +export HELLO=hello +echo $hello echo $ @@ -274,31 +275,9 @@ echo "$" echo '$' -echo \$ - -echo "\$" - -export HELLO=hello -echo \$HELLO - -export HELLO=hello -echo \\$HELLO - export HELLO=hello echo "$HELLO" -export HELLO=hello -echo "\$HELLO" - -export HELLO=hello -echo "\\$HELLO" - -export HELLO=hello -echo \\"$HELLO" - -export HELLO=hello -echo "\"\"$HELLO" - export TEST=ech "$TEST"o hello @@ -321,3 +300,4 @@ echo $abcdefghijklmnopqrstuvwxyz_ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890 export TEST="export TEST=echo" $TEST hello $TEST hello + diff --git a/tests/defaults/redirections.sh b/tests/defaults/redirections.sh index 8d4d4f0..dd10b02 100644 --- a/tests/defaults/redirections.sh +++ b/tests/defaults/redirections.sh @@ -168,18 +168,6 @@ echo hallo >x1 >x2 >x3 > file | cat < no_such_file -echo hello > out1.txt > out2.txt > out3.txt 2> err1.txt 2> err2.txt 2> err3.txt; cat out1.txt out2.txt out3.txt err1.txt err2.txt err3.txt - -echo hello >> out1.txt >> out2.txt >> out3.txt 2>> err1.txt 2>> err2.txt 2>> err3.txt; cat out1.txt out2.txt out3.txt err1.txt err2.txt err3.txt - -ls > out1.txt > out2.txt > out3.txt 2> err1.txt 2> err2.txt 2> err3.txt; cat out1.txt out2.txt out3.txt err1.txt err2.txt err3.txt - -ls >> out1.txt >> out2.txt >> out3.txt 2>> err1.txt 2>> err2.txt 2>> err3.txt; cat out1.txt out2.txt out3.txt err1.txt err2.txt err3.txt - -ls no_such_file > out1.txt > out2.txt > out3.txt 2> err1.txt 2> err2.txt 2> err3.txt; cat out1.txt out2.txt out3.txt err1.txt err2.txt err3.txt - -ls no_such_file >> out1.txt >> out2.txt >> out3.txt 2>> err1.txt 2>> err2.txt 2>> err3.txt; cat out1.txt out2.txt out3.txt err1.txt err2.txt err3.txt - echo a > out echo b >> out echo c >> out @@ -199,25 +187,6 @@ echo hello 2147483648> file echo a > $NO_ENV | echo b unset NO_ENV -./a.out 3> file3 2> file2 1> file1 -cat file3 file2 file1 -printf '#include\nint main(){write(1, "fd1\\n", 4);write(2, "fd2\\n", 4);write(3, "fd3\\n", 4);}' > a.c && gcc a.c - -./a.out 1> file1 2> file2 3> file3 -cat file1 file2 file3 -printf '#include\nint main(){write(1, "fd1\\n", 4);write(2, "fd2\\n", 4);write(3, "fd3\\n", 4);}' > a.c && gcc a.c - -echo a 1> 1.txt 2> 2.txt 3> 3.txt -./a.out 1>> 1.txt 2>> 2.txt 3>> 3.txt -cat 1.txt 2.txt 3.txt -printf '#include\nint main(){write(1, "fd1\\n", 4);write(2, "fd2\\n", 4);write(3, "fd3\\n", 4);}' > a.c && gcc a.c - -echo a 3> 3.txt 2> 2.txt 1> 1.txt 2> 2.txt 3> 3.txt -echo b 1>> 1.txt 2>> 2.txt 3>> 3.txt 2>> 2.txt 1>> 1.txt -./a.out 1>> 1.txt 2>> 2.txt 3>> 3.txt 2>> 2.txt 1>> 1.txt -cat 1.txt 2.txt 3.txt -printf '#include\nint main(){write(1, "fd1\\n", 4);write(2, "fd2\\n", 4);write(3, "fd3\\n", 4);}' > a.c && gcc a.c - echo a > f echo b >> f cat f f f >> ff diff --git a/tests/false_positive.sh b/tests/false_positive.sh index d6dd51b..349e68c 100644 --- a/tests/false_positive.sh +++ b/tests/false_positive.sh @@ -12,9 +12,52 @@ echo $? #--------------------------------------------- # Race condition, unpredictable behaviour + echo DOET HET NIET > test1 | cat test1 +#--------------------------------------------- +# redirection stderr + +echo hello > out1.txt > out2.txt > out3.txt 2> err1.txt 2> err2.txt 2> err3.txt +cat out1.txt out2.txt out3.txt err1.txt err2.txt err3.txt + +echo hello >> out1.txt >> out2.txt >> out3.txt 2>> err1.txt 2>> err2.txt 2>> err3.txt +cat out1.txt out2.txt out3.txt err1.txt err2.txt err3.txt + +ls > out1.txt > out2.txt > out3.txt 2> err1.txt 2> err2.txt 2> err3.txt +cat out1.txt out2.txt out3.txt err1.txt err2.txt err3.txt + +ls >> out1.txt >> out2.txt >> out3.txt 2>> err1.txt 2>> err2.txt 2>> err3.txt +cat out1.txt out2.txt out3.txt err1.txt err2.txt err3.txt + +ls no_such_file > out1.txt > out2.txt > out3.txt 2> err1.txt 2> err2.txt 2> err3.txt +cat out1.txt out2.txt out3.txt err1.txt err2.txt err3.txt + +ls no_such_file >> out1.txt >> out2.txt >> out3.txt 2>> err1.txt 2>> err2.txt 2>> err3.txt +cat out1.txt out2.txt out3.txt err1.txt err2.txt err3.txt + +./a.out 3> file3 2> file2 1> file1 +cat file3 file2 file1 +printf '#include\nint main(){write(1, "fd1\\n", 4);write(2, "fd2\\n", 4);write(3, "fd3\\n", 4);}' > a.c && gcc a.c + +./a.out 1> file1 2> file2 3> file3 +cat file1 file2 file3 +printf '#include\nint main(){write(1, "fd1\\n", 4);write(2, "fd2\\n", 4);write(3, "fd3\\n", 4);}' > a.c && gcc a.c + +echo a 1> 1.txt 2> 2.txt 3> 3.txt +./a.out 1>> 1.txt 2>> 2.txt 3>> 3.txt +cat 1.txt 2.txt 3.txt +printf '#include\nint main(){write(1, "fd1\\n", 4);write(2, "fd2\\n", 4);write(3, "fd3\\n", 4);}' > a.c && gcc a.c + +echo a 3> 3.txt 2> 2.txt 1> 1.txt 2> 2.txt 3> 3.txt +echo b 1>> 1.txt 2>> 2.txt 3>> 3.txt 2>> 2.txt 1>> 1.txt +./a.out 1>> 1.txt 2>> 2.txt 3>> 3.txt 2>> 2.txt 1>> 1.txt +cat 1.txt 2.txt 3.txt +printf '#include\nint main(){write(1, "fd1\\n", 4);write(2, "fd2\\n", 4);write(3, "fd3\\n", 4);}' > a.c && gcc a.c + + + #---------------------------------------------- # ; Semicolon separator @@ -551,3 +594,24 @@ echo \{ echo \} echo \~ +echo \$ + +echo "\$" + +export HELLO=hello +echo \$HELLO + +export HELLO=hello +echo \\$HELLO + +export HELLO=hello +echo "\$HELLO" + +export HELLO=hello +echo "\\$HELLO" + +export HELLO=hello +echo \\"$HELLO" + +export HELLO=hello +echo "\"\"$HELLO"