Skip to content

Commit

Permalink
Update postData.sh: Fix: send stderr to stdout so error messages work
Browse files Browse the repository at this point in the history
Without "2>&1", the "latitude" variable is set to "", so the following error message doesn't say anything.
  • Loading branch information
EricClaeys authored Aug 7, 2024
1 parent d3227a6 commit 225f509
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions scripts/postData.sh
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,14 @@ fi

if [[ ${SETTINGS_ONLY} == "false" ]]; then
OK="true"
if ! latitude="$( convertLatLong "$( settings ".latitude" )" "latitude" )" ; then
if ! latitude="$( convertLatLong "$( settings ".latitude" )" "latitude" 2>&1 )" ; then
OK="false"
echo -e "${RED}${ME}: ERROR: ${latitude}" >&2
if [[ ${FROM_WEBUI} == "false" ]]; then
"${ALLSKY_SCRIPTS}/addMessage.sh" "error" "${ME}: ${latitude}"
fi
fi
if ! longitude="$( convertLatLong "$( settings ".longitude" )" "longitude" )" ; then
if ! longitude="$( convertLatLong "$( settings ".longitude" )" "longitude" 2>&1 )" ; then
OK="false"
echo -e "${RED}${ME}: ERROR: ${longitude}" >&2
if [[ ${FROM_WEBUI} == "false" ]]; then
Expand All @@ -145,9 +145,9 @@ if [[ ${SETTINGS_ONLY} == "false" ]]; then

# If nighttime happens after midnight, sunwait returns "--:-- (Midnight sun)"
# If nighttime happens before noon, sunwait returns "--:-- (Polar night)"
sunrise="$( sunwait list rise angle "${angle}" "${latitude}" "${longitude}" )"
sunrise="$( sunwait list rise angle "${angle}" "${latitude}" "${longitude}" 2>&1 )"
sunrise_hhmm="${sunrise:0:5}"
sunset="$( sunwait list set angle "${angle}" "${latitude}" "${longitude}" )"
sunset="$( sunwait list set angle "${angle}" "${latitude}" "${longitude}" 2>&1 )"
sunset_hhmm="${sunset:0:5}"

if [[ ${sunrise_hhmm} == "--:--" || ${sunset_hhmm} == "--:--" ]]; then
Expand Down

0 comments on commit 225f509

Please sign in to comment.