summaryrefslogtreecommitdiff
path: root/tessen
diff options
context:
space:
mode:
authorJerzy Drozdz <jerzy.drozdz@jdsieci.pl>2022-01-24 07:01:08 +0100
committerGitHub <noreply@github.com>2022-01-24 11:31:08 +0530
commitc10030ae7816a6ef7a5612f038f2c7ec454a8c18 (patch)
treebe5a634b7520771f9a2c198994ce06d87adb1b6a /tessen
parent06e705fc593b5de63a37f04c210d7c7768884e12 (diff)
userkey search uses regex to find field (#11)
* userkey search uses regex to find field * Changed userkey default value to "user" * First matched entry will be set as tsn_username * Update to man page * Fixed setting userkey * Fixed typo
Diffstat (limited to 'tessen')
-rwxr-xr-xtessen8
1 files changed, 5 insertions, 3 deletions
diff --git a/tessen b/tessen
index 726ebdc..82a5203 100755
--- a/tessen
+++ b/tessen
@@ -22,7 +22,8 @@ readonly -a tsn_known_backends=('bemenu' 'fuzzel' 'rofi' 'wofi')
tsn_backend="${TESSEN_BACKEND-}"
tsn_backend_opts=()
tsn_action="${TESSEN_ACTION-}"
-tsn_userkey="${TESSEN_USERKEY:-user}"
+tsn_userkey_regex="${TESSEN_USERKEY:-user}"
+tsn_userkey="user"
tsn_urlkey="${TESSEN_URLKEY:-url}"
tsn_autokey="${TESSEN_AUTOKEY:-autotype}"
tsn_autotype=""
@@ -85,8 +86,9 @@ get_pass_data() {
# keys with the case insensitive name 'password' are ignored
if [[ "${key,,}" == "password" ]]; then
continue
- elif [[ "${key,,}" == "$tsn_userkey" ]]; then
+ elif [[ -z "${tsn_username}" ]] && [[ "${key,,}" =~ ^${tsn_userkey_regex}$ ]]; then
tsn_username="$val"
+ tsn_userkey="${key,,}"
elif [[ "${key,,}" == "$tsn_autokey" ]]; then
tsn_autotype="$val"
elif [[ "$idx" =~ $otp_regex ]]; then
@@ -96,7 +98,7 @@ get_pass_data() {
fi
done
- # if $tsn_userkey isn't found, use the basename of file as username
+ # if $tsn_userkey_regex isn't found, use the basename of file as username
if [[ -z "$tsn_username" ]]; then
tsn_username="${tsn_passfile##*/}"
fi