spm

Personal fork of spm (simple password manager)

commit bad9c32910d4f2621d3a3624c3da1c78957e6c7d
parent 1268209bd98da1820bdbc3743e9be46219327065
Author: Sören Tempel <soeren+git@soeren-tempel.net>
Date: Tue, 26 May 2015 19:23:35 +0200

Fix readpw function for non-terminal devices

Without this change a warning is written to stderr.
1 file changed, 6 insertions(+), 3 deletions(-)
M
tpm
|
9
++++++---
diff --git a/tpm b/tpm
@@ -43,10 +43,13 @@ abort() {
 }
 
 readpw() {
-  printf "${1}"
-  stty -echo
+  if [ -t 0 ]; then
+    printf "${1}"
+    stty -echo
+  fi
+
   IFS= read -r "${2}"
-  stty echo
+  [ -t 0 ] && stty echo
 }
 
 ##