From 5ffb2348f5c71356569b2acb5651b1a1646a926d Mon Sep 17 00:00:00 2001 From: miguel Date: Mon, 16 Jan 2023 16:30:34 +0000 Subject: [PATCH] fix(right) fixing the test, readme and solution --- sh/tests/right/sample1.txt | 0 sh/tests/right/sample2 | 0 sh/tests/right/sample3.txt | 0 sh/tests/right/sample4 | 0 sh/tests/right_test.sh | 16 +++++++++++++--- sh/tests/solutions/right.sh | 2 +- subjects/devops/right/README.md | 4 ++-- 7 files changed, 16 insertions(+), 6 deletions(-) delete mode 100644 sh/tests/right/sample1.txt delete mode 100644 sh/tests/right/sample2 delete mode 100644 sh/tests/right/sample3.txt delete mode 100644 sh/tests/right/sample4 diff --git a/sh/tests/right/sample1.txt b/sh/tests/right/sample1.txt deleted file mode 100644 index e69de29b..00000000 diff --git a/sh/tests/right/sample2 b/sh/tests/right/sample2 deleted file mode 100644 index e69de29b..00000000 diff --git a/sh/tests/right/sample3.txt b/sh/tests/right/sample3.txt deleted file mode 100644 index e69de29b..00000000 diff --git a/sh/tests/right/sample4 b/sh/tests/right/sample4 deleted file mode 100644 index e69de29b..00000000 diff --git a/sh/tests/right_test.sh b/sh/tests/right_test.sh index 1fb898e8..9524bba7 100755 --- a/sh/tests/right_test.sh +++ b/sh/tests/right_test.sh @@ -8,11 +8,21 @@ IFS=' FILENAME="student/right.sh" script_dirS=$(cd -P "$(dirname "$BASH_SOURCE")" &>/dev/null && pwd) +if test ! -e right; then + mkdir right + cd right + touch sample1.txt sample2 sample3.txt sample4 + cd .. +fi + challenge() { - submitted=$(cd "$1" && bash "$script_dirS"/$FILENAME) - expected=$(cd "$1" && bash "$script_dirS"/solutions/right.sh) + $(cd "$1" && bash "$script_dirS"/$FILENAME) + submitted=$(cat $1/filtered_files.txt) + rm $1"/filtered_files.txt" + $(cd "$1" && bash "$script_dirS"/solutions/right.sh) + expected=$(cat $1/filtered_files.txt) diff <(echo "$submitted") <(echo "$expected") - diff $1"/filtered_files_sol.txt" $1"/filtered_files.txt" } challenge right +rm -r right diff --git a/sh/tests/solutions/right.sh b/sh/tests/solutions/right.sh index 6c799cf4..cd411826 100755 --- a/sh/tests/solutions/right.sh +++ b/sh/tests/solutions/right.sh @@ -1 +1 @@ -ls | grep -v "\.txt" >filtered_files_sol.txt +ls | grep -v "\.txt" >filtered_files.txt diff --git a/subjects/devops/right/README.md b/subjects/devops/right/README.md index 988b108e..f885e7c1 100644 --- a/subjects/devops/right/README.md +++ b/subjects/devops/right/README.md @@ -20,9 +20,9 @@ $ ### Hints -command1 | command2 > output_file +`command1 | command2 > output_file` -Here, command1 is the command that generates the output you want to parse, and command2 is the command that parses the output. The output of command2 will be redirected to the file output_file using the > operator. +Here, `command1` is the command that generates the output you want to parse, and `command2` is the command that parses the output. The output of `command2` will be redirected to the file `output_file` using the `>` operator. > You have to use Man or Google to know more about commands flags, in order to solve this exercise! > Google and Man will be your friends!