[PATCH 1/1] compare-trees: drop getopt to allow long opts and fix exits

2 views
Skip to first unread message

Rob Browning

unread,
Jul 1, 2022, 6:02:53 PM7/1/22
to bup-...@googlegroups.com
Signed-off-by: Rob Browning <r...@defaultvalue.org>
---

Proposed.

dev/compare-trees | 20 +++++++++-----------
1 file changed, 9 insertions(+), 11 deletions(-)

diff --git a/dev/compare-trees b/dev/compare-trees
index aeaa086a..584a5c7e 100755
--- a/dev/compare-trees
+++ b/dev/compare-trees
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

-set -u
+set -euo pipefail

# Test that src and dest trees are as identical as bup is capable of
# making them. For now, use rsync -niaHAX ...
@@ -20,22 +20,20 @@ EOF

verify_content=" --checksum"

-while getopts "hcx" OPTION
-do
- case "$OPTION" in
- h) usage; exit 0;;
- c) verify_content=" --checksum";;
- x) verify_content="";;
- ?) usage 1>&2; exit 1;;
+while test $# -gt 0; do
+ case "$1" in
+ -h) usage; exit 0;;
+ -c) verify_content=" --checksum"; shift;;
+ -x) verify_content=""; shift;;
+ -*) usage 1>&2; exit 2;;
+ [^-]*) break;;
esac
done

-shift $(($OPTIND - 1)) || exit $?
-
if ! test $# -eq 2
then
usage 1>&2
- exit 1
+ exit 2
fi

src="$1"
--
2.30.2

Rob Browning

unread,
Jul 9, 2022, 2:45:39 PM7/9/22
to bup-...@googlegroups.com
Rob Browning <r...@defaultvalue.org> writes:

> Signed-off-by: Rob Browning <r...@defaultvalue.org>

Pushed.

--
Rob Browning
rlb @defaultvalue.org and @debian.org
GPG as of 2011-07-10 E6A9 DA3C C9FD 1FF8 C676 D2C4 C0F0 39E9 ED1B 597A
GPG as of 2002-11-03 14DD 432F AE39 534D B592 F9A0 25C8 D377 8C7E 73A4
Reply all
Reply to author
Forward
0 new messages