bin: Handle zero-match case in passget
This commit is contained in:
parent
de2065a17b
commit
c9e97d63cd
1 changed files with 4 additions and 1 deletions
|
|
@ -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
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue