diff --git a/bin/sekrit.sh b/bin/sekrit.sh index 1a144bc..98d65bd 100644 --- a/bin/sekrit.sh +++ b/bin/sekrit.sh @@ -29,11 +29,11 @@ usage() { cat - <<. >&2 Usage: - ${0##*/} add key [value ...] - ${0##*/} gen [-l length] [chars] - ${0##*/} get key - ${0##*/} has key - ${0##*/} ls [keys ...] + ${0##*/} add key [value ...] + ${0##*/} gen [-l length] [chars] + ${0##*/} get key + ${0##*/} has key + ${0##*/} ls [keys ...] If no value was provided on command line, add reads from stdin. . @@ -90,7 +90,7 @@ sekrit_gen() l) len=$(to_number "$OPTARG") || err "Invalid password length." ;; - [?]) usage + *) usage ;; esac done @@ -116,7 +116,7 @@ sekrit_get() shift f=$SEKRIT_DIR/$key.gpg - [ ! -f "$f" ] && err "No data for key \"$key\"." + [ -f "$f" ] || err "No data for key \"$key\"." gpg2 -qd "$f" } @@ -133,8 +133,8 @@ sekrit_has() ls_key() { d=$SEKRIT_DIR$1 - find "$d" -type f -name "*.gpg" | sort | cut -c $((${#d} + 1))- | - sed "s/\.gpg$//" + find "$d" -type f -name "*.gpg" | sort | + sed -e "s#^$d##" -e "s#\.gpg\$##" } sekrit_ls() @@ -162,7 +162,7 @@ umask 077 mkdir -p "$SEKRIT_DIR" case "$cmd" in -add) sekrit_add "$@";; +add) sekrit_add "$@" ;; gen) sekrit_gen "$@" ;; get) sekrit_get "$@" ;; has) sekrit_has "$@" ;;