diff options
author | Xiao Pan <gky44px1999@gmail.com> | 2024-02-28 05:08:56 -0800 |
---|---|---|
committer | Xiao Pan <gky44px1999@gmail.com> | 2024-02-28 05:08:56 -0800 |
commit | cc052298172c999a68ea46cc0e7d7fa900eb8b45 (patch) | |
tree | 1b653db1121f6bf665a1df7241c1dd3af025bd7c | |
parent | 3146dfbba6bc855dc566c1fb73709a7398dc5db2 (diff) |
New script prp, to practice password without print password on-screen
-rwxr-xr-x | sh/news | 2 | ||||
-rwxr-xr-x | sh/prp | 20 |
2 files changed, 21 insertions, 1 deletions
@@ -17,7 +17,7 @@ daily () { o alacritty --hold -e wtr o alacritty -e newsboat o alacritty --hold -e rate - o alacritty --hold -e pass practice_password2 + o alacritty --hold -e prp } monthly () { @@ -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" |