From 5c70c985ad528a14e630d9486f81686c33cbf585 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Mon, 2 Dec 2013 10:01:50 +0100 Subject: remove dependency of bash to hide username MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- DEPENDENCIES | 2 +- gotrc-examples/hide-username | 26 ++++++++++++++++++++++---- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/DEPENDENCIES b/DEPENDENCIES index 5a671ea..85b55df 100644 --- a/DEPENDENCIES +++ b/DEPENDENCIES @@ -3,7 +3,7 @@ RUNTIME DEPENDENCIES: util-linux login login is used for authorisation and login util-linux setsid used to start login in a new session -bash bash (out-out) gates-of-tartaros is written in Bash; required for hide-username +bash bash (out-out) gates-of-tartaros is written in Bash dash dash (opt-in) gates-of-tartaros is compatible with Dash openssh ssh (optional) used for SSH login coreutils env (opt-out) used to get the path to Bash in the shebangs diff --git a/gotrc-examples/hide-username b/gotrc-examples/hide-username index 3c86304..c9d01a0 100644 --- a/gotrc-examples/hide-username +++ b/gotrc-examples/hide-username @@ -1,16 +1,34 @@ # -*- shell-script -*- -# This module requires that got runs under GNU Bash. - # This module hides the username when it is types, # this can be useful so that nopony can se your # passphrase if you type it in instead of your # username by mistake when you log in. -_read () + +read_function_hide_username=$read_function +read_function=_read_hide_username + +_read_hide_username () { - read -s user + local _read_tty_settings + _read_tty_settings = "$(stty --save)" + stty -echo + + $read_function_hide_username + + stty "${_read_tty_settings}" echo } + +# If you use GNU Bash for gates-of-tartaros, +# you can use this instead: + +# _read () +# { +# read -s user +# echo +# } + -- cgit v1.2.3-70-g09d2