summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Bobov <abobov@gmail.com>2016-07-25 13:42:24 +0500
committerAnton Bobov <abobov@gmail.com>2016-07-25 13:42:24 +0500
commitb7731a8240ddfa73ece9d5e052fe59c6b58b8771 (patch)
tree89cc8e760a809e7d9bbc0e68a19b0834699be191
parent5cfe5ab48aec461e84514e43aa97e04ff8bbf808 (diff)
Fix empty lines in price.db when no exchange rate was returned.
-rwxr-xr-xledger-price-db-update.sh7
1 files changed, 5 insertions, 2 deletions
diff --git a/ledger-price-db-update.sh b/ledger-price-db-update.sh
index ff10504..084b27c 100755
--- a/ledger-price-db-update.sh
+++ b/ledger-price-db-update.sh
@@ -17,5 +17,8 @@ xe() {
curl -s "http://download.finance.yahoo.com/d/quotes.csv?s=$1&f=p"
}
-echo P $(date +"%Y/%m/%d %H:%M:%S") \$ $(xe "USDRUB=X") R >> "$PRICE_DB_FILE"
-echo P $(date +"%Y/%m/%d %H:%M:%S") € $(xe "EURRUB=X") R >> "$PRICE_DB_FILE"
+usd=$(xe "USDRUB=X")
+eur=$(xe "EURRUB=X")
+
+test -n "$usd" && echo P $(date +"%Y/%m/%d %H:%M:%S") \$ $usd R >> "$PRICE_DB_FILE"
+test -n "$eur" && echo P $(date +"%Y/%m/%d %H:%M:%S") € $eur R >> "$PRICE_DB_FILE"