From 483f8591087dc1b6ee2a1e167ff02a7050066611 Mon Sep 17 00:00:00 2001 From: Ostap Date: Sun, 6 Feb 2022 03:13:19 +0200 Subject: [PATCH] solve ex02 --- ex02/ex02.sh | 12 ++++++++++++ ex02/test_ex02.sh | 6 +++--- 2 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 ex02/ex02.sh diff --git a/ex02/ex02.sh b/ex02/ex02.sh new file mode 100644 index 0000000..a9f1754 --- /dev/null +++ b/ex02/ex02.sh @@ -0,0 +1,12 @@ +#! /bin/bash + +for file in $1 +do + path=$(ls -R ./ | grep ${file}) + if [ -z "${path}" ] + then + echo "the searched PATH is unexisting" + else + echo "${path}" + fi +done diff --git a/ex02/test_ex02.sh b/ex02/test_ex02.sh index a92433f..03f4464 100755 --- a/ex02/test_ex02.sh +++ b/ex02/test_ex02.sh @@ -3,7 +3,7 @@ #set -xe @test "Existing path STR" { - run ./ex02.sh "STR" + run bash ex02.sh "STR" [ "$status" -eq 0 ] [ "$output" = $'STR\n./resources/FOLDER/STR:' ] } @@ -14,14 +14,14 @@ [ "$output" = $'FOLDER\n./resources/FOLDER:\n./resources/FOLDER/STR:' ] } -@test "2 existing paths" { +@test "2 existing paths (1)" { run bash ex02.sh "STR FOLDER" [ "$status" -eq 0 ] [ "$output" = $'STR\n./resources/FOLDER/STR:\nFOLDER\n./resources/FOLDER:\n./resources/FOLDER/STR:' ] } -@test "2 existing paths" { +@test "2 existing paths (2)" { run bash ex02.sh "FOLDER STR" [ "$status" -eq 0 ] [ "$output" = $'FOLDER\n./resources/FOLDER:\n./resources/FOLDER/STR:\nSTR\n./resources/FOLDER/STR:' ]