aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAyush Agarwal <ayush@fastmail.in>2021-11-14 13:01:43 +0530
committerAyush Agarwal <ayush@fastmail.in>2021-11-14 13:01:43 +0530
commite8c2182b96c360bfa5d6b925c909c81466743e5a (patch)
tree26491f72302f7e8fdb253a4e81fb6a0a0496d67f
parent95111487107a063b00907f7c7dbc1289fcbd0513 (diff)
fix: don't proceed if selected file is empty
-rwxr-xr-xtessen9
1 files changed, 5 insertions, 4 deletions
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
}