Добавил хэлперы для if
This commit is contained in:
parent
f93a74941f
commit
03a637ca7a
11
src/condition.sh
Normal file
11
src/condition.sh
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
equal() {
|
||||||
|
local RETURN
|
||||||
|
RETURN=0
|
||||||
|
if [[ "$1" = "$2" ]];
|
||||||
|
then
|
||||||
|
RETURN=1
|
||||||
|
fi
|
||||||
|
echo $RETURN
|
||||||
|
}
|
24
src/condition.test.sh
Normal file
24
src/condition.test.sh
Normal file
@ -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
|
Loading…
Reference in New Issue
Block a user