1
0
Fork 0

bin: Handle zero-match case in passget

This commit is contained in:
Jeremy Kaplan 2019-11-15 14:38:01 -08:00
commit c9e97d63cd

View file

@ -17,7 +17,10 @@ set -euo pipefail
url="$1" url="$1"
mapfile -t matches < <(op list items | jq -c '.[] | select(.overview.url and (.overview.url | contains("'"${url}"'"))) | { uuid: .uuid, url: .overview.url }') mapfile -t matches < <(op list items | jq -c '.[] | select(.overview.url and (.overview.url | contains("'"${url}"'"))) | { uuid: .uuid, url: .overview.url }')
if [ "${#matches[@]}" -eq 1 ]; then if [ "${#matches[@]}" -eq 0 ]; then
>&2 echo "No matches found for ${url}"
exit 1
elif [ "${#matches[@]}" -eq 1 ]; then
item="${matches[0]}" item="${matches[0]}"
uuid="$(echo "${item}" | jq -r '.uuid')" uuid="$(echo "${item}" | jq -r '.uuid')"
else else