From be310b54683f1951becde31e2d55d332809f1ebb Mon Sep 17 00:00:00 2001 From: epoch Date: Thu, 14 Nov 2019 07:50:35 +0000 Subject: added ability to use negative all as an amount --- bin/xchg.buy | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'bin') diff --git a/bin/xchg.buy b/bin/xchg.buy index a0a3a8a..6d6d647 100755 --- a/bin/xchg.buy +++ b/bin/xchg.buy @@ -23,6 +23,17 @@ if [ "$source" = "" ];then exit 1 fi +if [ $amount = "-all" ];then #we're selling all + amount="100%" + merp=$source + source=$target + target=$merp +fi + +if [ $amount = "all" ];then + amount="100%" +fi + rate=1 #if [ $target != BTC ];then @@ -56,12 +67,9 @@ if [ "$walletdst" = "" ];then fi ### if other types of ways of specifying how much are added, remember to set both srcamt and amount. -if [ $amount = "all" ];then - amount="100%" -fi if grep '%' <<< "$amount" 2>&1 > /dev/null;then - percentage="$(printf "%s\n" "$amount" | tr -cd '0-9.')" - srcamt="$(echo | awk "{print ($percentage / 100) * $walletsrc}")" + percentage="$(printf "%s\n" "$amount" | tr -cd '0-9.-')" + srcamt="$(echo | awk "{print ( $percentage / 100) * $walletsrc}")" amount=$(echo | awk "{print $srcamt / $rate}") else srcamt=$(echo | awk "{print $amount * $rate}") -- cgit v1.2.3