From e4d74a176393fcfb125ca7d1a48945572c8b6b24 Mon Sep 17 00:00:00 2001 From: Federico Angelilli Date: Tue, 2 Jan 2024 19:02:03 +0100 Subject: Improve empty crypt handling --- crypt.sh | 6 +++--- extra/crypt.zsh | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/crypt.sh b/crypt.sh index 2dba8d3..c3e6849 100755 --- a/crypt.sh +++ b/crypt.sh @@ -630,7 +630,7 @@ cmd_show() { [[ -z $path ]] && path="$CRYPT_PATH" cmd_list "$path" elif [[ -z "$path" ]]; then - error "Try to initialize the crypt" + error "Try to initialize the crypt." else [[ $CLOSED -eq 1 ]] && error "The crypt must be open to show a file." @@ -644,7 +644,7 @@ cmd_show() { elif [[ -f "$CRYPT_PATH/$path" ]]; then _cmd_action_file "$path" show else - error "Try to initialize the crypt" + error "Try to initialize the crypt." fi fi } @@ -726,9 +726,9 @@ cmd_verify() { # TODO: Verify all the signatures in the crypt [[ $# -gt 1 ]] && error "$PROGRAM $COMMAND [--sign] [file]" Usage [[ -n $CRYPT_SIGNING_KEY ]] || error "No signing key was specified!" + [[ -d "$CRYPT_PATH" ]] || error "Try to initialize the crypt." local to_verify=() - if [[ $# -eq 1 ]]; then local path="$CRYPT_PATH/${1%/}" check_paths "$path" diff --git a/extra/crypt.zsh b/extra/crypt.zsh index 2e1e57a..3055baf 100755 --- a/extra/crypt.zsh +++ b/extra/crypt.zsh @@ -7,7 +7,7 @@ _crypt() { local IFS=$'\n' local location zstyle -s ":completion:${curcontext}:" location location || location="${CRYPT_PATH:-$HOME/.crypt}" - _values -C 'entries' ${$(crypt list --plain | sed -e "s#\([^[:space:]]*\)[[:space:]]*\(.*\)#\1\[\2\]#g" | sort):-""} + _values -C 'entries' ${$(crypt list --plain 2>/dev/null | sed -e "s#\([^[:space:]]*\)[[:space:]]*\(.*\)#\1\[\2\]#g" | sort):-""} } _crypt -- cgit v1.2.3