diff options
Diffstat (limited to 'livetimes.sh')
-rwxr-xr-x | livetimes.sh | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/livetimes.sh b/livetimes.sh index d4bd050..209bec8 100755 --- a/livetimes.sh +++ b/livetimes.sh @@ -77,13 +77,15 @@ _nextbus() { fi # select all stops from todays trips for a given service_number where stop_name contains "Bus Station Stand" nextbus=$(echo $timetables | jq -r --arg day "$day" --arg stop "$stop" '.timetables[] | select(.service_number == $stop) | .timetable.outbound[$day].trips[].stops[] | select(.stop_name | contains("Bus Station Stand"))') - echo $nextbus > foo.json for json in $(echo "${nextbus}" | jq -r '. | @base64'); do if [[ $(_jq '.departure_time') > $time ]]; then echo "Route $stop leaving from $(_jq '.stop_name') at $(_jq '.departure_time')" exit 0 fi done + # if program didn't exit inside for loop then we know the next bus is actually tomorrow in which case we'll return the zeroth item of the array + echo $(echo "Route $stop leaving from $(echo $nextbus | jq -s '.[0].stop_name') at $(echo $nextbus | jq -s '.[0].departure_time')" | sed 's/"//g') + exit 0 } #stop=$(echo ${stop^^}) |