Prefered C style boolean values

This commit is contained in:
deajan 2016-10-21 15:29:49 +02:00
parent d844a5b696
commit 1366b0c10c
2 changed files with 15 additions and 14 deletions

View File

@ -4,7 +4,7 @@ PROGRAM="osync" # Rsync based two way sync engine with fault tolerance
AUTHOR="(C) 2013-2016 by Orsiris de Jong" AUTHOR="(C) 2013-2016 by Orsiris de Jong"
CONTACT="http://www.netpower.fr/osync - ozy@netpower.fr" CONTACT="http://www.netpower.fr/osync - ozy@netpower.fr"
PROGRAM_VERSION=1.2-beta2 PROGRAM_VERSION=1.2-beta2
PROGRAM_BUILD=2016102101 PROGRAM_BUILD=2016102102
IS_STABLE=no IS_STABLE=no
# Execution order #__WITH_PARANOIA_DEBUG # Execution order #__WITH_PARANOIA_DEBUG
@ -171,7 +171,7 @@ function CheckCurrentConfigAll {
exit 1 exit 1
fi fi
if [ "$SKIP_DELETION" != "" ] && [ $(arrayContains "${INITIATOR[$__type]}" "${SKIP_DELETION[@]}") -ne 0 ] && [ $(arrayContains "${TARGET[$__type]}" "${SKIP_DELETION[@]}") -ne 0 ]; then if [ "$SKIP_DELETION" != "" ] && [ $(arrayContains "${INITIATOR[$__type]}" "${SKIP_DELETION[@]}") -eq 0 ] && [ $(arrayContains "${TARGET[$__type]}" "${SKIP_DELETION[@]}") -eq 0 ]; then
Logger "Bogus skip deletion parameter." "CRITICAL" Logger "Bogus skip deletion parameter." "CRITICAL"
exit 1 exit 1
fi fi
@ -1172,7 +1172,7 @@ function deletionPropagation {
#TODO: deletionPropagation replicaType = source replica whereas _deleteXxxxxx replicaType = dest replica #TODO: deletionPropagation replicaType = source replica whereas _deleteXxxxxx replicaType = dest replica
if [ "$replicaType" == "${INITIATOR[$__type]}" ]; then if [ "$replicaType" == "${INITIATOR[$__type]}" ]; then
if [ $(arrayContains "${INITIATOR[$__type]}" "${SKIP_DELETION[@]}") -ne 0 ]; then if [ $(arrayContains "${INITIATOR[$__type]}" "${SKIP_DELETION[@]}") -eq 0 ]; then
replicaDir="${INITIATOR[$__replicaDir]}" replicaDir="${INITIATOR[$__replicaDir]}"
deleteDir="${INITIATOR[$__deleteDir]}" deleteDir="${INITIATOR[$__deleteDir]}"
@ -1186,7 +1186,7 @@ function deletionPropagation {
Logger "Skipping deletion on replica $replicaType." "NOTICE" Logger "Skipping deletion on replica $replicaType." "NOTICE"
fi fi
elif [ "$replicaType" == "${TARGET[$__type]}" ]; then elif [ "$replicaType" == "${TARGET[$__type]}" ]; then
if [ $(arrayContains "${TARGET[$__type]}" "${SKIP_DELETION[@]}") -ne 0 ]; then if [ $(arrayContains "${TARGET[$__type]}" "${SKIP_DELETION[@]}") -eq 0 ]; then
replicaDir="${TARGET[$__replicaDir]}" replicaDir="${TARGET[$__replicaDir]}"
deleteDir="${TARGET[$__deleteDir]}" deleteDir="${TARGET[$__deleteDir]}"

View File

@ -1,6 +1,6 @@
#### MINIMAL-FUNCTION-SET BEGIN #### #### MINIMAL-FUNCTION-SET BEGIN ####
## FUNC_BUILD=2016102101 ## FUNC_BUILD=2016102102
## BEGIN Generic bash functions written in 2013-2016 by Orsiris de Jong - http://www.netpower.fr - ozy@netpower.fr ## BEGIN Generic bash functions written in 2013-2016 by Orsiris de Jong - http://www.netpower.fr - ozy@netpower.fr
## To use in a program, define the following variables: ## To use in a program, define the following variables:
@ -872,19 +872,20 @@ function IsNumericExpand {
local re="^-?[0-9]+([.][0-9]+)?$" local re="^-?[0-9]+([.][0-9]+)?$"
if [[ $value =~ $re ]]; then if [[ $value =~ $re ]]; then
echo 1 echo 1 && return 1
else else
echo 0 echo 0 && return 0
fi fi
} }
# Usage [ $(IsNumeric $var) -eq 1 ]
function IsNumeric { function IsNumeric {
local value="${1}" local value="${1}"
if [[ $value =~ ^[0-9]+([.][0-9]+)?$ ]]; then if [[ $value =~ ^[0-9]+([.][0-9]+)?$ ]]; then
echo 1 echo 1 && return 1
else else
echo 0 echo 0 && return 0
fi fi
} }
@ -892,9 +893,9 @@ function IsInteger {
local value="${1}" local value="${1}"
if [[ $value =~ ^[0-9]+$ ]]; then if [[ $value =~ ^[0-9]+$ ]]; then
echo 1 echo 1 && return 1
else else
echo 0 echo 0 && return 0
fi fi
} }
@ -928,13 +929,13 @@ arrayContains () {
local e local e
if [ "$2" == "" ]; then if [ "$2" == "" ]; then
echo 1 && return 1 echo 0 && return 0
fi fi
for e in "${@:2}"; do for e in "${@:2}"; do
[[ "$e" == "$1" ]] && echo 0 && return 0 [[ "$e" == "$1" ]] && echo 1 && return 1
done done
echo 1 && return 1 echo 0 && return 0
} }
function GetLocalOS { function GetLocalOS {