summaryrefslogtreecommitdiff
path: root/livetimes.sh
diff options
context:
space:
mode:
Diffstat (limited to 'livetimes.sh')
-rwxr-xr-xlivetimes.sh8
1 files changed, 6 insertions, 2 deletions
diff --git a/livetimes.sh b/livetimes.sh
index 6f0feb1..55d143f 100755
--- a/livetimes.sh
+++ b/livetimes.sh
@@ -17,7 +17,6 @@ _liveresult() {
result="$result Route: $(_jq '.service_number')\n"
done
echo -e $result
- # is this the correct exit code?
exit 0
}
@@ -28,6 +27,9 @@ _stopsreturn() {
if [ $stopslen = 1 ]; then
stop=$(echo ${stops} | jq '.[].stop_id')
_liveresult
+ elif [ $stopslen = 0 ]; then
+ echo "No results found."
+ exit 1
# multiple stops returned in $stops so we will return stop names and codes so user can retry
else
for json in $(echo "${stops}" | jq -r '.[] | @base64'); do
@@ -35,7 +37,6 @@ _stopsreturn() {
result="$result Code: $(_jq '.stop_id')\n"
done
echo -e $result
- # is this the correct exit code?
exit 0
fi
}
@@ -46,6 +47,9 @@ if [ "$stop" == "-h" ] || [ "$stop" == "--help" ]; then
exit 0
elif [[ "$stop" =~ ^-?[0-9]+$ ]] && [ $(echo ${#stop} == 4) ]; then
_liveresult
+elif [[ -z "${stop// }" ]]; then
+ echo "Input empty. Usage: '!livetimes <stop>' where <stop> is either the 4 digit stop code, the full unique or partial bus stop name. If a bus stop name is used and there are multiple matches then a list of matching stops will be returned with their codes."
+ exit 1
else
_stopsreturn
fi