From 4c0ebba02447a417a3e9dfff55a248106d9f03b6 Mon Sep 17 00:00:00 2001 From: yehorrudytsia Date: Sun, 31 Oct 2021 16:12:27 +0200 Subject: [PATCH 1/2] ex01 --- ex01/hello_world.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 ex01/hello_world.sh diff --git a/ex01/hello_world.sh b/ex01/hello_world.sh new file mode 100644 index 0000000..969e537 --- /dev/null +++ b/ex01/hello_world.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +hello_world() { + if [ -n "${1}" ]; + then echo "Hello, ${1}!" + else echo "Hello, World!" + fi +} + +hello_world $1 From 7766567286b7745fce5096099e52b3ef3f10328b Mon Sep 17 00:00:00 2001 From: yehorrudytsia Date: Sun, 31 Oct 2021 16:50:13 +0200 Subject: [PATCH 2/2] ex02 --- ex02/ex02.sh | 13 +++++++++++++ ex02/test_ex02.sh | 7 +++---- 2 files changed, 16 insertions(+), 4 deletions(-) create mode 100644 ex02/ex02.sh diff --git a/ex02/ex02.sh b/ex02/ex02.sh new file mode 100644 index 0000000..c56694a --- /dev/null +++ b/ex02/ex02.sh @@ -0,0 +1,13 @@ +#!/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..0c3111b 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 STR FOLDER" { 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 FOLDER STR" { run bash ex02.sh "FOLDER STR" [ "$status" -eq 0 ] [ "$output" = $'FOLDER\n./resources/FOLDER:\n./resources/FOLDER/STR:\nSTR\n./resources/FOLDER/STR:' ] @@ -61,4 +61,3 @@ -