From 71ae0af4bad2fd38ded15bcb643f0ad73232c480 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Mon, 30 Sep 2013 03:09:49 +0200 Subject: get rid of python MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- got | 45 ++++++++++++++++++++++++++++++++++----------- 1 file changed, 34 insertions(+), 11 deletions(-) (limited to 'got') diff --git a/got b/got index 429f70f..b41091a 100755 --- a/got +++ b/got @@ -18,30 +18,53 @@ # along with this program. If not, see . -if [ "$1" = "---" ]; then +if [ "$1" = "-" ]; then tty="$2" shift 2 + export "$@" + + function _login + { + read user + if [ ! "${user/@/}" = "${user}" ]; then + export GOT_COMMAND="ssh ${user}" + login -p -f sshlogin + elif [ "${user::1}" = "-" ]; then + stty -icanon -echo -isig -ix{on,off,any} + echo $'\e[01;31mNice try! Sleeping for 10 minutes...\e[00m' + sleep 600 + else + login -- "${user}" + fi + } + + function _display + { + echo -en '\e[H\e[2J' + echo -e "\e[${ANSI_COLOR}m${NAME} (${tty})\e[00m" + echo + echo -n 'Login: ' + } + NAME="$(uname -o)" ANSI_COLOR='01;34' # must be exactly ANSI_COLOR as it is defined in /etc/os-release if [ -f "@etc@/os-release" ]; then . "@etc@/os-release" fi - if [ -f "@etc@/@command@rc" ]; then . "@etc@/@command@rc" - else - echo -en '\e[H\e[2J' - echo -e "\e[${ANSI_COLOR}m${NAME} (${tty})\e[00m" - echo - echo -n 'Login: ' fi - tty_settings="$(stty --save)" - @prefix@@libexec@/@command@.py "$@" - stty "${tty_settings}" + _display + _login else + # cannot get any other solution to work with `login` + # then to spawn a new process with pipes preset + tty="/dev/$1" - "$0" --- "$@" > "${tty}" 2> "${tty}" < "${tty}" + tty_settings="$(stty --save)" + "$0" - "$@" > "${tty}" 2> "${tty}" < "${tty}" + stty "${tty_settings}" fi -- cgit v1.2.3-70-g09d2