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

Commit a349f9d

Browse files
authored
Disable nounset bash option when calculating cidr (#782)
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
1 parent 637ca25 commit a349f9d

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

ova/scripts/systemd/scripts/network-config.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,13 @@ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
2121
source "${SCRIPT_DIR}/ovfenv_wrapper.sh"
2222

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

2933
netConfig=''

0 commit comments

Comments
 (0)