SHA256
Compare commits
2
Commits
| Author | SHA256 | Date | |
|---|---|---|---|
|
|
01c299e242
|
||
|
|
56b619372d
|
@@ -1,5 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -o pipefail
|
||||
|
||||
function usage() {
|
||||
local full=${1:-false}
|
||||
cat <<EOF
|
||||
@@ -181,24 +183,27 @@ function may_select() {
|
||||
}
|
||||
|
||||
function select_group() {
|
||||
local groups
|
||||
readarray -t groups < <(get_group_names)
|
||||
(( ${#groups[@]} == 0 )) && return 2
|
||||
local groups raw
|
||||
raw=$(get_group_names) || { echo "Error: failed to query PBS!" >&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; }
|
||||
@@ -355,9 +360,10 @@ case "$action" in
|
||||
target=${args[2]}
|
||||
|
||||
if [ -z "$target" ]; then
|
||||
[ ! -t 0 ] && echo "Error: no target path given and stdin is not a terminal" >&2 && exit 1
|
||||
while [ -z "$target" ]; do
|
||||
echo -n "Target path: "
|
||||
read -r target
|
||||
! read -r target && [ -z "$target" ] && echo "Error: no target path given" >&2 && exit 1
|
||||
[ -d "$target" ] && break
|
||||
echo -e "\nError: $target: no such directory\n" >&2
|
||||
target=''
|
||||
|
||||
Reference in New Issue
Block a user