From e8c2182b96c360bfa5d6b925c909c81466743e5a Mon Sep 17 00:00:00 2001 From: Ayush Agarwal Date: Sun, 14 Nov 2021 13:01:43 +0530 Subject: fix: don't proceed if selected file is empty --- tessen | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'tessen') diff --git a/tessen b/tessen index 0c46f3a..e542425 100755 --- a/tessen +++ b/tessen @@ -29,20 +29,21 @@ declare -A tsn_passdata tsn_username="" tsn_password="" -# display and get the shortened path of the password file +# FIRST MENU: generate a list of password store files, let the user select one get_pass_file() { local -a tmp_list - # temporarily enable globbing to get the list of gpg files + # temporarily enable globbing, get the list of all gpg files recursively, + # remove PASSWORD_STORE_DIR from the file names, and remove the '.gpg' suffix shopt -s nullglob globstar tmp_list=("$tsn_prefix"/**/*.gpg) tmp_list=("${tmp_list[@]#"$tsn_prefix"/}") tmp_list=("${tmp_list[@]%.gpg}") shopt -u nullglob globstar - tsn_passfile="$(printf '%s\n' "${tmp_list[@]}" | "$tsn_backend" "$tsn_backend_opts")" + tsn_passfile="$(printf "%s\n" "${tmp_list[@]}" | "$tsn_backend" "$tsn_backend_opts")" - if ! [[ -e "$tsn_prefix/$tsn_passfile".gpg ]]; then + if ! [[ -s "$tsn_prefix/$tsn_passfile".gpg ]]; then exit 1 fi } -- cgit v1.2.3