commit e8c2182b96c360bfa5d6b925c909c81466743e5a parent 95111487107a063b00907f7c7dbc1289fcbd0513 Author: Ayush Agarwal <ayush@fastmail.in> Date: Sun, 14 Nov 2021 13:01:43 +0530 fix: don't proceed if selected file is empty Diffstat:
| M | tessen | | | 9 | +++++---- |
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git 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 }