From 4c60341519bc0471b07a049143400cc2112c83c6 Mon Sep 17 00:00:00 2001 From: Ayush Agarwal Date: Wed, 8 Sep 2021 01:02:47 +0530 Subject: add trap and reorganize global vars --- tessen | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/tessen b/tessen index 2dda3b6..9e12b11 100755 --- a/tessen +++ b/tessen @@ -7,20 +7,13 @@ readonly PATH="/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin" export PATH umask 077 +# initialize the global variables BACKEND="bemenu" CLIP_TIME=15 WTYPE="" - - -readonly CLIP_TIME -readonly BACKEND -readonly WTYPE - - -# initialize the primary global variables readonly PASS_STORE="${PASSWORD_STORE_DIR:-$HOME/.password-store}" -PASSFILE="" # password file chosen by the user for decryption -declare -A PASSDATA_ARR # decrypted password-store data except the password +PASSFILE="" +declare -A PASSDATA_ARR USERNAME="" PASSWORD="" CHOICE="" @@ -241,9 +234,14 @@ main() { unset -v opt shift $((OPTIND - 1)) + readonly WTYPE + readonly BACKEND + readonly CLIP_TIME + validate_backend validate_clip_time + trap 'die' EXIT TERM get_pass_file get_pass_data @@ -254,6 +252,7 @@ main() { choice_data_copy key_menu_copy fi + trap - EXIT TERM } main "$@" -- cgit v1.2.3