summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorepoch <epoch@hack.thebackupbox.net>2019-11-14 07:50:35 +0000
committerepoch <epoch@hack.thebackupbox.net>2019-11-14 07:50:35 +0000
commitbe310b54683f1951becde31e2d55d332809f1ebb (patch)
tree0c18921dd08a3add88f990dda5e9b890b73050f6 /bin
parent093037c14055355d2fee55c25f4fc5899c4232d6 (diff)
downloadsegfault_home-be310b54683f1951becde31e2d55d332809f1ebb.tar.gz
segfault_home-be310b54683f1951becde31e2d55d332809f1ebb.zip
added ability to use negative all as an amount
Diffstat (limited to 'bin')
-rwxr-xr-xbin/xchg.buy18
1 files changed, 13 insertions, 5 deletions
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}")