From d59a588295e04658324aedc65ddfa1298e933c62 Mon Sep 17 00:00:00 2001 From: Siphonight Date: Mon, 10 Mar 2025 13:09:35 +0100 Subject: [PATCH] =?UTF-8?q?Am=C3=83liorations=20du=20script=20de=20d=C3=83?= =?UTF-8?q?connection=20de=20base?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ajout de la condition trap utilisant la fonction identities_destroy en cas de fermeture du TTY parent par la commande exit. Cela permettra de fermer les terminaux sans devoir toujours penser à utiliser manuellement **"identities_destroy"** --- bw_cli_autolog.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/bw_cli_autolog.sh b/bw_cli_autolog.sh index 889ede5..f0f05f7 100644 --- a/bw_cli_autolog.sh +++ b/bw_cli_autolog.sh @@ -1,9 +1,9 @@ - +# shellcheck disable=SC2148 identities_create() { # IDENTITES Inception_Detect=0 - if [ -z "${BW_Session}" ] || [ $(echo "${BW_Session}" | wc -c) -lt 10 ]; then + if [ -z "${BW_Session}" ] || [ "$(echo "${BW_Session}" | wc -c)" -lt 10 ]; then tput setaf 4 echo -e "Lancement du autologin (ne prenez pas en compte les tokens, ils sont gérés automatiquement)." tput sgr0 @@ -11,6 +11,7 @@ identities_create() { local Bitwarden_Email="" local Bitwarden_Server="" bw config server "${Bitwarden_Server}" + # shellcheck disable=SC2155 export BW_Session="$(bw login "${Bitwarden_Email}" | tee /dev/tty | grep -m1 '==' | cut -d '"' -f 2)" Inception_Detect=1 fi @@ -65,3 +66,7 @@ identities_destroy() { } identities_create + +if [[ -n ${BW_Session} ]]; then + trap identities_destroy EXIT +fi