commit fd7fd1e825362fd916ff07361ef4494e26af6997 parent d2cf8b5af2308cbb36cbf2f90fc8bae941112cfb Author: Javier Sepulveda <javier.sepulveda@uv.es> Date: Fri, 22 Sep 2023 12:29:03 +0200 Fix error unbound variable - Set to zero Diffstat:
| M | sandcastle/utils/fund-rewards.sh | | | 9 | ++++++++- |
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git 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.