Skip to content
This repository has been archived by the owner on Nov 16, 2020. It is now read-only.

Commit

Permalink
Disable nounset bash option when calculating cidr (#782)
Browse files Browse the repository at this point in the history
The mask2cdr function's implementation is based on the default behavior
of unset variables. by importing ovfenv_wrapper we enabled the nounset
flag, which causes mask2cdr function to fail with unbound variable
error.

nounset is helpful to detect errors as most variables should
  • Loading branch information
kars7e authored Nov 30, 2018
1 parent 637ca25 commit a349f9d
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ova/scripts/systemd/scripts/network-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,13 @@ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
source "${SCRIPT_DIR}/ovfenv_wrapper.sh"

mask2cdr () {
# mask2cdr implementation is based on the behavior of unbound variables.
# because of that we need to ensure that "nounset" option is disabled for it.
set +u
set -- 0^^^128^192^224^240^248^252^254^ ${#1} ${1##*255.}
set -- $(( ($2 - ${#3})*2 )) ${1%%${3%%.*}*}
echo $(( $1 + (${#2}/4) ))
set -u
}

netConfig=''
Expand Down

0 comments on commit a349f9d

Please sign in to comment.