From 3afa7371bfcf72666ef2bf5f4e15eb6ca5dc253a Mon Sep 17 00:00:00 2001 From: Robert Günzler Date: Wed, 20 Apr 2022 19:21:27 +0200 Subject: bin/b2: simplify hashing option --- bin/b2 | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'bin') diff --git a/bin/b2 b/bin/b2 index c24b318..07d1976 100755 --- a/bin/b2 +++ b/bin/b2 @@ -13,17 +13,17 @@ canonical_uri() { list= delete= hash= -while getopts H:ldh opt; do +while getopts Hldh opt; do case "$opt" in l) list=1 ;; d) delete=1 ;; - H) hash=${OPTARG} ;; + H) hash=1 ;; h | ?) printf "usage: %s [-hld] [FILE] [DESTINATION]\n" "$(basename "$0")" printf "\n" printf " -l list\n" printf " -d delete\n" - printf " -H FILE hash\n" + printf " -H hash as filename\n" printf "\n" printf "The default action is to put the FILE into the remote bucket\n" exit 2 @@ -51,8 +51,7 @@ fi if [ -n "$hash" ]; then ext="$(echo "${file}" | rev | cut -d\. -f1 | rev | sed -e "s#${file}##")" [ -n "$ext" ] && ext=".${ext}" - [ "$hash" = "self" ] && hash=$file - sum=$(md5sum "$hash" | cut -d\ -f1) + sum=$(md5sum "$file" | cut -d\ -f1) dest=$(echo "${dest}" | sed -e "s#$(basename "${file}")#${sum}${ext}#") fi -- cgit 1.4.1