aboutsummaryrefslogtreecommitdiffstats
path: root/network-scripts
diff options
context:
space:
mode:
authorDavid Kaspar [Dee'Kej] <dkaspar@redhat.com>2018-07-30 14:15:24 +0200
committerDee'Kej <deekej@linuxmail.org>2018-08-03 12:57:38 +0200
commit27724e4df026baa6def7d44ed08f4b8a7c1fdec7 (patch)
tree1fce23a7e4e05b101129f01c8a8cd734ddd427ae /network-scripts
parentde16adb62bfc62cdfb2fce185d83bfe157c41803 (diff)
downloadinitscripts-27724e4df026baa6def7d44ed08f4b8a7c1fdec7.tar
initscripts-27724e4df026baa6def7d44ed08f4b8a7c1fdec7.tar.gz
initscripts-27724e4df026baa6def7d44ed08f4b8a7c1fdec7.tar.bz2
initscripts-27724e4df026baa6def7d44ed08f4b8a7c1fdec7.tar.xz
initscripts-27724e4df026baa6def7d44ed08f4b8a7c1fdec7.zip
ifup-eth: use 'bc' instead of 'expr' when computing $forward_delay
Because the return value of 'convert2sec()' function can sometimes be decimal, the follow up 'expr' call can fail, since 'expr' does not support floating point calculations. This can sometimes lead to error: """ expr: non-integer argument /etc/sysconfig/network-scripts/ifup-eth: line 91: [: 0: unary operator expected """ To solve this bug, we switch to 'bc' utility, which supports floating point computations. We also have to change the comparison condition of $LINKDELAY and $forward_delay to use 'bc' as well.
Diffstat (limited to 'network-scripts')
-rwxr-xr-xnetwork-scripts/ifup-eth6
1 files changed, 4 insertions, 2 deletions
diff --git a/network-scripts/ifup-eth b/network-scripts/ifup-eth
index b55db79e..73a6c834 100755
--- a/network-scripts/ifup-eth
+++ b/network-scripts/ifup-eth
@@ -89,9 +89,11 @@ if [ "${TYPE}" = "Bridge" ]; then
forward_delay="$(convert2sec ${forward_delay} centi)"
fi
- forward_delay=$(expr ${forward_delay} \* 2 + 7)
+ forward_delay=$(bc -q <<< "${forward_delay} * 2 + 7")
- [ 0$LINKDELAY -lt $forward_delay ] && LINKDELAY=$forward_delay
+ # It's possible we are comparing floating point numbers here, therefore
+ # we are using 'bc' for comparison. The [ ] and [[ ]] do not work.
+ (( $(bc -l <<< "${LINKDELAY:-0} < ${forward_delay}") )) && LINKDELAY=${forward_delay}
unset forward_delay
fi