diff options
author | Javier Sepulveda <javier.sepulveda@uv.es> | 2023-09-22 12:29:03 +0200 |
---|---|---|
committer | Javier Sepulveda <javier.sepulveda@uv.es> | 2023-09-22 12:31:38 +0200 |
commit | fd7fd1e825362fd916ff07361ef4494e26af6997 (patch) | |
tree | 9313cbfb04b58495e5e98e2b0b4e68bf34763b79 | |
parent | d2cf8b5af2308cbb36cbf2f90fc8bae941112cfb (diff) | |
download | deployment-fd7fd1e825362fd916ff07361ef4494e26af6997.tar.gz deployment-fd7fd1e825362fd916ff07361ef4494e26af6997.tar.bz2 deployment-fd7fd1e825362fd916ff07361ef4494e26af6997.zip |
Fix error unbound variable - Set to zero
-rwxr-xr-x | sandcastle/utils/fund-rewards.sh | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/sandcastle/utils/fund-rewards.sh b/sandcastle/utils/fund-rewards.sh index cf09723..d53bd99 100755 --- a/sandcastle/utils/fund-rewards.sh +++ b/sandcastle/utils/fund-rewards.sh @@ -38,9 +38,16 @@ JSON=$(taler-harness deployment tip-status \ # Calculate remaining funds ACTIVE_FUNDS=$(echo "$JSON" | jq '[.reserves[] | select(.active)]') -TOTAL_EXCHANGE_INITIAL_AMOUNT=$(echo "$ACTIVE_FUNDS" | jq --arg cur "$CURRENCY" '[.[].exchange_initial_amount | sub($cur + ":"; "") | tonumber] | add') + +# If there is ANY active reserve, then do the substraction +if [[ $ACTIVE_FUNDS != "[]" ]]; then +TOTAL_EXCHANGE_INITIAL_AMOUNT=$(echo "$ACTIVE_FUNDS" | jq --arg cur "$CURRENCY" '[.[].exchange_initial_amount | sub($cur + ":"; "") | tonumber] |> TOTAL_PICKUP_AMOUNT=$(echo "$ACTIVE_FUNDS" | jq --arg cur "$CURRENCY" '[.[].pickup_amount | sub($cur + ":"; "") | tonumber] | add') TOTAL_RESERVE_AMOUNT=$((TOTAL_EXCHANGE_INITIAL_AMOUNT - TOTAL_PICKUP_AMOUNT)) +else +# Otherwise set variable to zero +TOTAL_RESERVE_AMOUNT=0 +fi # Decide whether add a new reserve, or leave it as is. |