Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-ports
Path: blob/main/misc/ansiweather/files/patch-ansiweather
18157 views
--- ansiweather.orig	2016-10-18 17:14:59 UTC
+++ ansiweather
@@ -205,7 +205,7 @@ then
 	forecast=$([ "$forecast" -gt "$flength" ] && echo "$flength" || echo "$forecast")
 else
 	city=$(echo "$weather" | jq -r '.name')
-	temperature=$(echo "$weather" | jq '.main.temp' | xargs printf "%.0f")
+	temperature=$(echo "$weather" | jq '.main.temp' | xargs gprintf "%.0f")
 	humidity=$(echo "$weather" | jq '.main.humidity')
 	pressure=$(echo "$weather" | jq '.main.pressure')
 	sky=$(echo "$weather" | jq -r '.weather[0].main')
@@ -285,7 +285,7 @@ case $units in
 		scale="°C"
 		speed_unit="m/s"
 		pressure_unit="hPa"
-		pressure=$(echo "$pressure" | xargs printf "%.0f")
+		pressure=$(echo "$pressure" | xargs gprintf "%.0f")
 		;;
 	imperial)
 		scale="°F"
@@ -293,7 +293,7 @@ case $units in
 		pressure_unit="inHg"
 		if [ "$forecast" = 0 ]
 		then
-			pressure=$(echo "$pressure*0.0295" | bc | xargs printf "%.2f")
+			pressure=$(echo "$pressure*0.0295" | bc | xargs gprintf "%.2f")
 		fi
 		;;
 esac
@@ -349,8 +349,8 @@ then
 	do
 		day=$(echo "$weather" | jq ".list[$i]")
 		date=$(epoch_to_date "$(echo "$day" | jq -r '.dt')")
-		low=$(echo "$day" | jq -r '.temp.min' | xargs printf "%.0f")
-		high=$(echo "$day" | jq -r '.temp.max' | xargs printf "%.0f")
+		low=$(echo "$day" | jq -r '.temp.min' | xargs gprintf "%.0f")
+		high=$(echo "$day" | jq -r '.temp.max' | xargs gprintf "%.0f")
 
 		icon=""
 		if [ "$symbols" = true ]
@@ -397,7 +397,7 @@ fi
 
 if [ "$ansi" = true ]
 then
-	env printf "$output\033[0m\n"
+	env gprintf "$output\033[0m\n"
 else
-	env printf "$output\n" | sed "s/$(printf '\033')\[[0-9;]*m//g"
+	env gprintf "$output\n" | sed "s/$(gprintf '\033')\[[0-9;]*m//g"
 fi