From 2db94f49c07946220659e1a9540cc2cb95d255f4 Mon Sep 17 00:00:00 2001 From: Damon Revoe Date: Wed, 15 Apr 2020 10:42:08 -0400 Subject: [PATCH] Replace bc with shell arithmetic The variable MEM_GIG was computed using bc, an arbitrary precision calculator. That caused a numeric comparison that used that variable in scripts/eosio_build_darwin.sh to fail when the scale was set to a value greater than zero in the user's ~/.bc configuration file. This commit fixes the problem by switching to shell arithmetic when computing MEM_GIG. --- scripts/helpers/general.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/helpers/general.sh b/scripts/helpers/general.sh index 37244e42415..6a55d1736c8 100755 --- a/scripts/helpers/general.sh +++ b/scripts/helpers/general.sh @@ -63,7 +63,7 @@ function set_system_vars() { export OS_MAJ=$(echo "${OS_VER}" | cut -d'.' -f1) export OS_MIN=$(echo "${OS_VER}" | cut -d'.' -f2) export OS_PATCH=$(echo "${OS_VER}" | cut -d'.' -f3) - export MEM_GIG=$(bc <<< "($(sysctl -in hw.memsize) / 1024000000)") + export MEM_GIG=$(($(sysctl -in hw.memsize) / 1024 / 1024 /1024)) export DISK_INSTALL=$(df -h . | tail -1 | tr -s ' ' | cut -d\ -f1 || cut -d' ' -f1) export blksize=$(df . | head -1 | awk '{print $2}' | cut -d- -f1) export gbfactor=$(( 1073741824 / blksize )) @@ -379,4 +379,4 @@ function ensure-apt-packages() { echo "" fi IFS=$OLDIFS -} \ No newline at end of file +}