* Changed name for _log function to _msg, added bail() function.
* Created _ansi function library to set terminal properties like cursor position and text color. * Created _if function library, a set of simple if statements. Added _if_array_contains, _if_is_integer, _if_is defined, if_has_value
This commit is contained in:
parent
5f446594ee
commit
fca165b274
9 changed files with 476 additions and 141 deletions
26
test/test-if.sh
Normal file
26
test/test-if.sh
Normal file
|
@ -0,0 +1,26 @@
|
|||
#!/bin/bash
|
||||
|
||||
source "../lib/if.sh"
|
||||
|
||||
echo "_if_array_contains test started"
|
||||
for result in 2 2 0 1; do
|
||||
echo "Exit code should be ${result}"
|
||||
eArray=(aa ab 0 dsa 2)
|
||||
i=${result}
|
||||
_if_array_contains "${i}" "${eArray[@]}"
|
||||
echo $?
|
||||
done
|
||||
echo "_if_array_contains test ended"
|
||||
|
||||
echo "_if_is_integer test started"
|
||||
for result in 0 1; do
|
||||
echo "Exit code should be ${result}"
|
||||
if [ ${result} == 0 ]; then
|
||||
i=0
|
||||
else
|
||||
i=a
|
||||
fi
|
||||
_if_is_integer ${i}
|
||||
echo $?
|
||||
done
|
||||
echo "_if_is_integer test ended"
|
Reference in a new issue