From 03a637ca7ad3cec03b74a0475ed9a8fb50b149b0 Mon Sep 17 00:00:00 2001 From: Sipachev Igor Date: Tue, 16 Aug 2022 15:24:46 +0700 Subject: [PATCH 1/2] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB?= =?UTF-8?q?=20=D1=85=D1=8D=D0=BB=D0=BF=D0=B5=D1=80=D1=8B=20=D0=B4=D0=BB?= =?UTF-8?q?=D1=8F=20if?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/condition.sh | 11 +++++++++++ src/condition.test.sh | 24 ++++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 src/condition.sh create mode 100644 src/condition.test.sh diff --git a/src/condition.sh b/src/condition.sh new file mode 100644 index 0000000..94b6607 --- /dev/null +++ b/src/condition.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +equal() { + local RETURN + RETURN=0 + if [[ "$1" = "$2" ]]; + then + RETURN=1 + fi + echo $RETURN +} diff --git a/src/condition.test.sh b/src/condition.test.sh new file mode 100644 index 0000000..4e43c9f --- /dev/null +++ b/src/condition.test.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +. ./condition.sh + +# equal +if [ $(equal 1 1) -eq 1 ] +then + echo "equal numeric" +fi + +if [[ $(equal 1 2) -eq 0 ]] +then + echo "not equal numeric" +fi + +if [[ $(equal "asdf" "asdf") -eq 1 ]] +then + echo "equal string" +fi + +if [[ $(equal "asdf" "asdf1") -eq 0 ]] +then + echo "not equal string" +fi From 017f0e2bdc0a0083d7442ef3ddcb8dee749d14dc Mon Sep 17 00:00:00 2001 From: Sipachev Igor Date: Tue, 16 Aug 2022 15:26:07 +0700 Subject: [PATCH 2/2] =?UTF-8?q?=D0=A3=D0=B1=D1=80=D0=B0=D0=BB=20=D1=84?= =?UTF-8?q?=D0=B0=D0=B9=D0=BB=D1=8B=20=D1=88=D1=82=D0=BE=D1=80=D0=BC=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index c795b05..8461078 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -build \ No newline at end of file +build +.idea