sharefile

scripts for quickly sharing data to servers
git clone git://jb55.com/sharefile
Log | Files | Refs | README

commit 48fa57204ab30e327c582b3590b71b72ec1db46e
parent 8ca1af0abf986b0881b38c32ed283bc07ba78d2a
Author: William Casarin <bill@casarin.me>
Date:   Mon, 22 Feb 2016 16:37:34 -0800

fix

Diffstat:
Mhashname | 17+++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/hashname b/hashname @@ -1,12 +1,17 @@ #!/usr/bin/env bash + hash=$(sha1sum "$1" | awk '{ print $1 }') hashlen=${2:-16} shorthash=${hash:0:$hashlen} filename=$(basename "$1") -if [[ $filename == *.* ]]; then - ext="${filename##*.}" - sfilename="${shorthash}.${ext}" -else - sfilename="${shorthash}" -fi + +case $filename in + *.*) + ext="${filename##*.}"; + sfilename="${shorthash}.${ext}" + ;; + *) + sfilename="${shorthash}" +esac + echo $sfilename