From d8980a0a9c906eb2be3d392eaafb4bf97d40b74f Mon Sep 17 00:00:00 2001 From: Alex Epstein Date: Wed, 2 Aug 2017 08:37:28 -0400 Subject: [PATCH] Replacing bc everywhere, currency exchange trys to use bc still --- cloudup/cloudup | 4 ++-- cryptocurrency/cryptocurrency | 7 ++++++- currency/currency | 8 +++++++- todo/todo | 4 ++-- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/cloudup/cloudup b/cloudup/cloudup index 6aec150..0d4acf9 100755 --- a/cloudup/cloudup +++ b/cloudup/cloudup @@ -167,7 +167,7 @@ getGithubRepoNames() for repo in $repoResponse; do ## go through each repo if [[ $source == "1" ]]; then ## if the user set the source flag if [[ ${forkResponse[$count]} == "false" ]]; then repoNames+=("$repo"); fi ## if they are the owner of the repository add it to the list of repoNames - count=$(echo $count + 1 | bc) ## increment the counter + count=$(( $count + 1 )) ## increment the counter else ## the user didnt set the source flag repoNames+=("$repo") ## add all repos in repoResponse to repoNames fi @@ -264,7 +264,7 @@ if [[ $all == "0" ]]; then backupRepo || { echo "Error: couldnt backup $repoName to bitbucket"; exit 1; } exit 0 else ## flags are set but arguments are also provided - firstArg=$(echo $private + $tStamp + 1 | bc) + firstArg=$(( $private + $tStamp + 1 )) getGitHubUserInfo || exit 1 getBitbucketInfo || exit 1 for i in "${@:$firstArg}"; do diff --git a/cryptocurrency/cryptocurrency b/cryptocurrency/cryptocurrency index fba3268..cc585a8 100755 --- a/cryptocurrency/cryptocurrency +++ b/cryptocurrency/cryptocurrency @@ -166,7 +166,12 @@ convertCurrency() { exchangeTo=$(echo "$exchangeTo" | tr '[:upper:]' '[:lower:]') exchangeRate=$(httpGet "https://api.coinmarketcap.com/v1/ticker/$reqId/?convert=$exchangeTo" | grep -Eo "\"price_$exchangeTo\": \"[0-9 .]*" | sed s/"\"price_$exchangeTo\": \""//g) > /dev/null - exchangeAmount=$(echo "$exchangeRate * $amount" | bc ) + if ! command -v bc; then + exchangeRate=$(echo $exchangeRate | grep -Eo "[0-9]*" ) + exchangeAmount=$(( $exchangeRate * $amount )) + else + exchangeAmount=$( echo "$exchangeRate * $amount" | bc ) + fi exchangeTo=$(echo "$exchangeTo" | tr '[:lower:]' '[:upper:]') base=$(echo "$base" | tr '[:lower:]' '[:upper:]') diff --git a/currency/currency b/currency/currency index e108512..b376418 100755 --- a/currency/currency +++ b/currency/currency @@ -137,7 +137,13 @@ checkInternet() convertCurrency() { exchangeRate=$(httpGet "http://api.fixer.io/latest?base=$base&symbols=$exchangeTo" | grep -Eo "[0-9]*[.][0-9]*") > /dev/null - exchangeAmount=$(echo "$exchangeRate * $amount" | bc) + if ! command -v bc; then + exchangeRate=$(echo $exchangeRate | grep -Eo "[0-9]*" ) + exchangeAmount=$(( $exchangeRate * $amount )) + else + exchangeAmount=$( echo "$exchangeRate * $amount" | bc ) + fi + cat <> ~/.todo/temp.txt;fi - count=$(echo $count + 1 | bc) + count=$(( $count + 1 )) done rm -f ~/.todo/list.txt cp ~/.todo/temp.txt ~/.todo/list.txt @@ -122,7 +122,7 @@ getTasks() for task in $(cat ~/.todo/list.txt); do if [ $count -lt 10 ]; then count="0$count"; fi echo "$count). $task" >> ~/.todo/getTemp.txt - count=$(echo $count + 1 | bc) + count=$(( $count + 1 )) done cat ~/.todo/getTemp.txt | column -t -s ";" rm -f ~/.todo/getTemp.txt