summaryrefslogtreecommitdiff
path: root/sh/prp
diff options
context:
space:
mode:
Diffstat (limited to 'sh/prp')
-rwxr-xr-xsh/prp20
1 files changed, 20 insertions, 0 deletions
diff --git a/sh/prp b/sh/prp
new file mode 100755
index 0000000..541b2ee
--- /dev/null
+++ b/sh/prp
@@ -0,0 +1,20 @@
+#!/bin/sh
+# PRactice Password
+
+read_pass () {
+ stty -echo
+ # -r necessary because password may contain backslash \
+ read -r entered_pass
+ stty echo
+}
+
+pass_name="${1:-practice_password2}"
+correct_pass="$(pass "$pass_name" | { IFS= read -r p; printf %s "$p";})"
+echo "Enter password \"$pass_name\":"
+read_pass
+# `| { IFS= read -r p; printf %s "$p"; }` steal from <https://git.zx2c4.com/password-store/tree/contrib/dmenu/passmenu#n34>, GPL-2.0-or-later; I use this because it is much faster than `| head -n1`
+while ! [ "$entered_pass" = "$correct_pass" ]; do
+ echo "Wrong password, enter again:"
+ read_pass
+done
+echo "Correct password"