From 56b619372dfb7083b4f10503ecff4444c94e8c8da7a1ad20cfd07679258ecb7e Mon Sep 17 00:00:00 2001 From: Thomas Oettli Date: Sat, 22 Aug 2026 07:39:16 +0200 Subject: [PATCH] report PBC query failures instead of an empty datastore --- pbc | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/pbc b/pbc index cc70793..190ee1c 100755 --- a/pbc +++ b/pbc @@ -1,5 +1,7 @@ #!/usr/bin/env bash +set -o pipefail + function usage() { local full=${1:-false} cat <&2; return 1; } + [ -z "$raw" ] && return 2 + readarray -t groups <<< "$raw" PS3="Snapshot group [1-${#groups[@]}]: " GROUP=$(may_select "$1" "${groups[@]}") || { echo "Error: invalid group" >&2; return 1; } } function select_snapshot_and_archive() { - local snapshots archives - readarray -t snapshots < <(get_snapshot_names) - (( ${#snapshots[@]} == 0 )) && return 2 + local snapshots archives raw + raw=$(get_snapshot_names) || { echo "Error: failed to query PBS!" >&2; return 1; } + [ -z "$raw" ] && return 2 + readarray -t snapshots <<< "$raw" PS3="Snapshot [1-${#snapshots[@]}]: " SNAPSHOT=$(may_select "$1" "${snapshots[@]}") || { echo "Error: invalid snapshot" >&2; return 1; } - readarray -t archives < <(get_snapshot_files "$SNAPSHOT") - (( ${#archives[@]} == 0 )) && return 3 + raw=$(get_snapshot_files "$SNAPSHOT") || { echo "Error: failed to query PBS!" >&2; return 1; } + [ -z "$raw" ] && return 3 + readarray -t archives <<< "$raw" PS3="Archive [1-${#archives[@]}]: " ARCHIVE=$(may_select "$2" "${archives[@]}") || { echo "Error: invalid archive" >&2; return 1; }