From 6458a147b3cb064a227df0efcdf873d3e30f1cdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20H=C3=B6tzel?= Date: Sun, 31 Oct 2021 19:26:34 +0100 Subject: [PATCH] Run keepassxc-cli in silent mode (prevent password prompt) This also removes the dependency on Unix grep command. Additional adjustments for Windows compatibility: Use absolute file name for db in shell command: This prevents issues with tilde expansion on Windows (cmd.exe). Don't quote password in echo command, because quotes are also echoed: https://stackoverflow.com/questions/804646/how-do-you-strip-quotes-out-of-an-echoed-string-in-a-windows-batch-file Use double-quotes for group-path: Single quotes don't have a special meaning in cmd.exe. Fixes #10 --- keepass-mode.el | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/keepass-mode.el b/keepass-mode.el index 62d6815..67c2aff 100644 --- a/keepass-mode.el +++ b/keepass-mode.el @@ -141,18 +141,18 @@ (defun keepass-mode-command (group command) "Generate KeePass COMMAND to run, on GROUP." - (format "echo %s | \ - keepassxc-cli %s %s %s 2>&1 | \ - egrep -v '[Insert|Enter] password to unlock %s'" - (shell-quote-argument keepass-mode-password) + (format "echo %s| \ + keepassxc-cli %s --quiet %s %s 2>&1" + (if (eq system-type 'windows-nt) + keepass-mode-password ;FIX Quoting issues on Windoes: + (shell-quote-argument keepass-mode-password)) command - keepass-mode-db - group - keepass-mode-db)) + (expand-file-name keepass-mode-db) + group)) (defun keepass-mode-quote-unless-empty (text) "Quote TEXT unless it's empty." - (if (= (length text) 0) text (format "'%s'" text))) + (if (= (length text) 0) text (format "\"%s\"" text))) (defun keepass-mode-get-value-from-alist (key alist) "Get the value for KEY from the ALIST."