Skip to content

Commit

Permalink
product-pricelimiter.sh print diff of price & limit
Browse files Browse the repository at this point in the history
If the system has bc installed, print the difference
between the price and the maximum price.
  • Loading branch information
oh2fih committed Aug 7, 2024
1 parent e3dd394 commit 40fe5c0
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions bin/product-pricelimiter.sh
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,19 @@ lower=$(printf "%s\n%s" "$price" "$maxprice" | sort -g | head -1)
if [ "$lower" = "$price" ]; then
echo -ne "\033[0;32mGood to buy! "
echo -e "The price (#$n in \"$selector\") is now $price €\033[0m"
if command -v bc &> /dev/null; then
diff=$(echo "scale=2; $maxprice - $price" | bc)
echo -ne "\033[0;32mThat is $diff € lower "
echo -e "than the max price ($maxprice €)\033[0m"
fi
exit 0
else
echo -ne "\033[0;33mPlease be patient! "
echo -e "The price (#$n in \"$selector\") is still $price €\033[0m"
if command -v bc &> /dev/null; then
diff=$(echo "scale=2; $price - $maxprice" | bc)
echo -ne "\033[0;33mThat is $diff € higher "
echo -e "than the max price ($maxprice €)\033[0m"
fi
exit 2
fi

0 comments on commit 40fe5c0

Please sign in to comment.