Skip to content

Commit

Permalink
Add -h and --help to qvm-copy
Browse files Browse the repository at this point in the history
Fixes: QubesOS/qubes-issues#8023
(cherry picked from commit 395a62b)
  • Loading branch information
DemiMarie authored and marmarek committed Mar 12, 2023
1 parent 618db8a commit 1c1f0c8
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions qubes-rpc/qvm-copy
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,7 @@ case ${0##*/} in
(*) printf 'Invoked with unrecognized name %s, cannot determine operation to perform\n' "$0"; exit 1;;
esac

if [ "$1" = "--without-progress" ] ; then
export PROGRESS_TYPE=none
shift
else
export PROGRESS_TYPE=console
fi

if [ "$1" = '--' ]; then shift; fi

if [ "$#" -lt "$MIN_ARGS" ]; then
usage () {
if [ "$TARGET_TYPE" = "vm" ]; then
echo "usage: $0 [--without-progress] destination_qube_name FILE [FILE ...]"
else
Expand All @@ -49,7 +40,7 @@ if [ "$#" -lt "$MIN_ARGS" ]; then

echo

if [ "$OPERATION_TYPE" = "move" ] ; then
if [ "$OPERATION_TYPE" = "move" ]; then
echo "Move FILE to ~/QubesIncoming/[THIS QUBE'S NAME]/ in the destination qube."
else
echo "Copy FILE to ~/QubesIncoming/[THIS QUBE'S NAME]/ in the destination qube."
Expand All @@ -60,8 +51,21 @@ if [ "$#" -lt "$MIN_ARGS" ]; then
if [ "$TARGET_TYPE" = "vm" ]; then
echo "In order to avoid typing target qube name twice, use qvm-copy/qvm-move instead of qvm-copy-to-vm/qvm-move-to-vm."
fi
exit 1
fi
exit "$1"
}

export PROGRESS_TYPE=console
while [ "$#" -gt 0 ]; do
case $1 in
(--without-progress) export PROGRESS_TYPE=none; shift;;
(-h|--help) usage 0;;
(--) shift; break;;
(-*) usage 1;;
(*) break;;
esac
done

if [ "$#" -lt "$MIN_ARGS" ]; then usage 1; fi

if [ "$TARGET_TYPE" = "vm" ]; then
VM="$1"
Expand All @@ -75,7 +79,7 @@ if [ "$PROGRESS_TYPE" = console ] ; then
export FILECOPY_TOTAL_SIZE
fi

for path in "$@"; do
for path; do
if [ ! -e "$path" ]; then
echo "File or directory not found: $path"
exit 1
Expand Down

0 comments on commit 1c1f0c8

Please sign in to comment.