penguin/utils

my env utils

commit 36c34d66442b70f05dd64b8cf67276603465fb6e

author斟酌 鵬兄 <tgckpg@gmail.com>
date2026-06-28T00:10:39Z
subjectVerify the key before saving
commit 36c34d66442b70f05dd64b8cf67276603465fb6e
Author: 斟酌 鵬兄 <tgckpg@gmail.com>
Date:   2026-06-28T00:10:39Z

    Verify the key before saving
---
 bash/sources/16_keystore | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/bash/sources/16_keystore b/bash/sources/16_keystore
index f96dba9..a99f626 100644
--- a/bash/sources/16_keystore
+++ b/bash/sources/16_keystore
@@ -461,15 +461,15 @@ function _kstoresecret-config {
 			return 1
 		fi
 
-		case $OSTYPE in
-			cygwin|linux|darwin*)
-				read -p "Save this password to OS's keystore? (y/n): " _CONFIRM
-				if [ "$_CONFIRM" != "y" ]; then
-					return 0
-				fi
+		# Test the key first
+		$_SQLITE -list "$_AUTH_DB" "SELECT ( data ) FROM $_KSTORE_TABLE LIMIT 1;" | _kstoredec >/dev/null
+		if [ $? -eq 0 ]; then
+			echo "" >&2
+			read -p "Save this password to OS's keystore? (y/n): " _CONFIRM
+			if [ "$_CONFIRM" == "y" ]; then
 				_kstoresecret-auto set
-			;;
-		esac
+			fi
+		fi
 	fi
 }