test may_select directly instead of $?

This commit is contained in:
2026-08-22 06:41:05 +02:00
parent ee86603dcd
commit e184d1c92c
+5 -10
View File
@@ -303,8 +303,7 @@ case "$action" in
args=("${args[@]:1}") args=("${args[@]:1}")
PS3="Snapshot group [1-${#groups[@]}]: " PS3="Snapshot group [1-${#groups[@]}]: "
group=$(may_select "$group" "${groups[@]}") group=$(may_select "$group" "${groups[@]}") || { echo "Error: invalid group" >&2; exit 1; }
(( $? != 0 )) && echo "Error: invalid group" >&2 && exit 1
echo echo
pbc-snapshot-list "$group" "${args[@]}" || exit $? pbc-snapshot-list "$group" "${args[@]}" || exit $?
@@ -317,8 +316,7 @@ case "$action" in
args=("${args[@]:1}") args=("${args[@]:1}")
PS3="Snapshot [1-${#snapshots[@]}]: " PS3="Snapshot [1-${#snapshots[@]}]: "
snapshot=$(may_select "$snapshot" "${snapshots[@]}") snapshot=$(may_select "$snapshot" "${snapshots[@]}") || { echo "Error: invalid snapshot" >&2; exit 1; }
(( $? != 0 )) && echo "Error: invalid snapshot" >&2 && exit 1
readarray -t archives < <(get_snapshot_files "$snapshot") readarray -t archives < <(get_snapshot_files "$snapshot")
(( ${#archives[@]} == 0 )) && echo "no archives found" && exit 0 (( ${#archives[@]} == 0 )) && echo "no archives found" && exit 0
@@ -327,8 +325,7 @@ case "$action" in
args=("${args[@]:1}") args=("${args[@]:1}")
PS3="Archive [1-${#archives[@]}]: " PS3="Archive [1-${#archives[@]}]: "
archive=$(may_select "$archive" "${archives[@]}") archive=$(may_select "$archive" "${archives[@]}") || { echo "Error: invalid archive" >&2; exit 1; }
(( $? != 0 )) && echo "Error: invalid archive" >&2 && exit 1
echo echo
pbc-catalog-shell "$snapshot" "$archive" || exit $? pbc-catalog-shell "$snapshot" "$archive" || exit $?
@@ -341,8 +338,7 @@ case "$action" in
args=("${args[@]:1}") args=("${args[@]:1}")
PS3="Snapshot [1-${#snapshots[@]}]: " PS3="Snapshot [1-${#snapshots[@]}]: "
snapshot=$(may_select "$snapshot" "${snapshots[@]}") snapshot=$(may_select "$snapshot" "${snapshots[@]}") || { echo "Error: invalid snapshot" >&2; exit 1; }
(( $? != 0 )) && echo "Error: invalid snapshot" >&2 && exit 1
readarray -t archives < <(get_snapshot_files "$snapshot") readarray -t archives < <(get_snapshot_files "$snapshot")
(( ${#archives[@]} == 0 )) && echo "no archives found" && exit 0 (( ${#archives[@]} == 0 )) && echo "no archives found" && exit 0
@@ -351,8 +347,7 @@ case "$action" in
args=("${args[@]:1}") args=("${args[@]:1}")
PS3="Archive [1-${#archives[@]}]: " PS3="Archive [1-${#archives[@]}]: "
archive=$(may_select "$archive" "${archives[@]}") archive=$(may_select "$archive" "${archives[@]}") || { echo "Error: invalid archive" >&2; exit 1; }
(( $? != 0 )) && echo "Error: invalid archive" >&2 && exit 1
target=${args[0]} target=${args[0]}
args=("${args[@]:1}") args=("${args[@]:1}")