fixed alias with spaces and printing with aliases

main
spinach 2 years ago
parent 62a2e6be80
commit b6eba78754

@ -5,7 +5,6 @@
usage() {
cat <<EOF
usage: $0 [-c][-p][-f][-s][-h][-r [option]]
Queries Bluebikes API to get recent bike status
Options:
@ -115,11 +114,9 @@ set_station_alias() {
exit 1
fi
# gojq hates qoutes
FMT_ALIAS=$(printf '"%s"' $(echo $ALIAS | tr -d '"'))
FMT_STATIONID=$(printf '"%d"' $STATION_ID)
echo "$(cat "$ALIASES_FILE" | gojq ".$FMT_STATIONID |= $FMT_ALIAS")" > "$ALIASES_FILE"
# adding to file
tmp=$(cat "$ALIASES_FILE" | gojq --arg name "$ALIAS" --arg id "$STATION_ID" 'setpath([$id]; $name)')
echo "$tmp" > "$ALIASES_FILE"
# printing change
if [[ -z "$ALIAS" ]] ; then
@ -181,7 +178,7 @@ print_status() {
id=$(printf '"%d"' $STATION_ID)
ALIAS=$(cat "$ALIASES_FILE" | gojq ".$id" | tr -d '"')
if [[ "$ALIAS" != "null" ]] ; then
if [[ "$ALIAS" != "null" && ! -z "$ALIAS" ]] ; then
# if there is an alias
STATION_NAME="$ALIAS"
fi

Loading…
Cancel
Save