From 1366b0c10cc36868e644d69fc68469946ea84a31 Mon Sep 17 00:00:00 2001 From: deajan Date: Fri, 21 Oct 2016 15:29:49 +0200 Subject: [PATCH] Prefered C style boolean values --- dev/n_osync.sh | 8 ++++---- dev/ofunctions.sh | 21 +++++++++++---------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/dev/n_osync.sh b/dev/n_osync.sh index 3b7a182..3edc52a 100755 --- a/dev/n_osync.sh +++ b/dev/n_osync.sh @@ -4,7 +4,7 @@ PROGRAM="osync" # Rsync based two way sync engine with fault tolerance AUTHOR="(C) 2013-2016 by Orsiris de Jong" CONTACT="http://www.netpower.fr/osync - ozy@netpower.fr" PROGRAM_VERSION=1.2-beta2 -PROGRAM_BUILD=2016102101 +PROGRAM_BUILD=2016102102 IS_STABLE=no # Execution order #__WITH_PARANOIA_DEBUG @@ -171,7 +171,7 @@ function CheckCurrentConfigAll { exit 1 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" exit 1 fi @@ -1172,7 +1172,7 @@ function deletionPropagation { #TODO: deletionPropagation replicaType = source replica whereas _deleteXxxxxx replicaType = dest replica 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]}" deleteDir="${INITIATOR[$__deleteDir]}" @@ -1186,7 +1186,7 @@ function deletionPropagation { Logger "Skipping deletion on replica $replicaType." "NOTICE" fi 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]}" deleteDir="${TARGET[$__deleteDir]}" diff --git a/dev/ofunctions.sh b/dev/ofunctions.sh index 93a9884..447060a 100644 --- a/dev/ofunctions.sh +++ b/dev/ofunctions.sh @@ -1,6 +1,6 @@ #### 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 ## To use in a program, define the following variables: @@ -872,19 +872,20 @@ function IsNumericExpand { local re="^-?[0-9]+([.][0-9]+)?$" if [[ $value =~ $re ]]; then - echo 1 + echo 1 && return 1 else - echo 0 + echo 0 && return 0 fi } +# Usage [ $(IsNumeric $var) -eq 1 ] function IsNumeric { local value="${1}" if [[ $value =~ ^[0-9]+([.][0-9]+)?$ ]]; then - echo 1 + echo 1 && return 1 else - echo 0 + echo 0 && return 0 fi } @@ -892,9 +893,9 @@ function IsInteger { local value="${1}" if [[ $value =~ ^[0-9]+$ ]]; then - echo 1 + echo 1 && return 1 else - echo 0 + echo 0 && return 0 fi } @@ -928,13 +929,13 @@ arrayContains () { local e if [ "$2" == "" ]; then - echo 1 && return 1 + echo 0 && return 0 fi for e in "${@:2}"; do - [[ "$e" == "$1" ]] && echo 0 && return 0 + [[ "$e" == "$1" ]] && echo 1 && return 1 done - echo 1 && return 1 + echo 0 && return 0 } function GetLocalOS {