From e184d1c92c71f2af1ee679e2decb81c3d19784fe2e1976d488d193c51a903387 Mon Sep 17 00:00:00 2001 From: Thomas Oettli Date: Sat, 22 Aug 2026 06:41:05 +0200 Subject: [PATCH] test may_select directly instead of $? --- pbc | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/pbc b/pbc index 02fa4fa..734530a 100755 --- a/pbc +++ b/pbc @@ -303,8 +303,7 @@ case "$action" in args=("${args[@]:1}") PS3="Snapshot group [1-${#groups[@]}]: " - group=$(may_select "$group" "${groups[@]}") - (( $? != 0 )) && echo "Error: invalid group" >&2 && exit 1 + group=$(may_select "$group" "${groups[@]}") || { echo "Error: invalid group" >&2; exit 1; } echo pbc-snapshot-list "$group" "${args[@]}" || exit $? @@ -317,8 +316,7 @@ case "$action" in args=("${args[@]:1}") PS3="Snapshot [1-${#snapshots[@]}]: " - snapshot=$(may_select "$snapshot" "${snapshots[@]}") - (( $? != 0 )) && echo "Error: invalid snapshot" >&2 && exit 1 + snapshot=$(may_select "$snapshot" "${snapshots[@]}") || { echo "Error: invalid snapshot" >&2; exit 1; } readarray -t archives < <(get_snapshot_files "$snapshot") (( ${#archives[@]} == 0 )) && echo "no archives found" && exit 0 @@ -327,8 +325,7 @@ case "$action" in args=("${args[@]:1}") PS3="Archive [1-${#archives[@]}]: " - archive=$(may_select "$archive" "${archives[@]}") - (( $? != 0 )) && echo "Error: invalid archive" >&2 && exit 1 + archive=$(may_select "$archive" "${archives[@]}") || { echo "Error: invalid archive" >&2; exit 1; } echo pbc-catalog-shell "$snapshot" "$archive" || exit $? @@ -341,8 +338,7 @@ case "$action" in args=("${args[@]:1}") PS3="Snapshot [1-${#snapshots[@]}]: " - snapshot=$(may_select "$snapshot" "${snapshots[@]}") - (( $? != 0 )) && echo "Error: invalid snapshot" >&2 && exit 1 + snapshot=$(may_select "$snapshot" "${snapshots[@]}") || { echo "Error: invalid snapshot" >&2; exit 1; } readarray -t archives < <(get_snapshot_files "$snapshot") (( ${#archives[@]} == 0 )) && echo "no archives found" && exit 0 @@ -351,8 +347,7 @@ case "$action" in args=("${args[@]:1}") PS3="Archive [1-${#archives[@]}]: " - archive=$(may_select "$archive" "${archives[@]}") - (( $? != 0 )) && echo "Error: invalid archive" >&2 && exit 1 + archive=$(may_select "$archive" "${archives[@]}") || { echo "Error: invalid archive" >&2; exit 1; } target=${args[0]} args=("${args[@]:1}")