diff options
| -rwxr-xr-x | got | 27 | ||||
| -rw-r--r-- | gotrc-examples/allow-uppercase | 8 | ||||
| -rw-r--r-- | gotrc-examples/commands | 2 | ||||
| -rw-r--r-- | gotrc-examples/issue-file | 2 | ||||
| -rw-r--r-- | gotrc-examples/lower-left-ponysay | 9 | ||||
| -rw-r--r-- | gotrc-examples/no-empty-user | 2 |
6 files changed, 29 insertions, 21 deletions
@@ -21,12 +21,11 @@ # Read the parameters: the first is the tty, the rest are exports tty="$1" shift 1 -export "$@" +if [ ! $# = 0 ]; then + export "$@" +fi # Change TTY -exec 0<&- -exec 1<&- -exec 2<&- exec 0<>"@dev@/${tty}" exec 1>&0 exec 2>&0 @@ -36,9 +35,17 @@ exec 2>&0 tty_settings="$(stty --save)" +# This is required if you want to use dash (and ash, since dash +# [dash not ash] does not recognise $''). +echo () +{ + @echo@ "$@" +} + + # Function used for printing information on the terminal for the user display_function=_display -function _display +_display () { echo -en '\e[H\e[2J' echo -e "\e[${ANSI_COLOR}m${NAME} (${tty})\e[00m" @@ -48,21 +55,21 @@ function _display # Function for reading the username form the terminal read_function=_read -function _read +_read () { read user } # Function for logging in the user login_function=_login -function _login +_login () { - if [ ! "${user/@/}" = "${user}" ]; then + if [ ! "${user%@*}" = "${user}" ]; then setsid -c @ssh@ ${user} || sleep 3 # The sleep allows you to see any error you made - elif [ "${user::1}" = "-" ]; then + elif [ "${user%%-*}" = "" ]; then stty -icanon -echo -isig -ix{on,off,any} - echo $'\e[01;31mNice try! Sleeping for 10 minutes...\e[00m' + echo -e '\e[01;31mNice try! Sleeping for 10 minutes...\e[00m' sleep 600 else setsid -c login -- "${user}" diff --git a/gotrc-examples/allow-uppercase b/gotrc-examples/allow-uppercase index a54c5f6..aa13d07 100644 --- a/gotrc-examples/allow-uppercase +++ b/gotrc-examples/allow-uppercase @@ -6,17 +6,17 @@ read_function_allow_uppercase=$read_function read_function=_read_allow_uppercase -function _read_allow_uppercase +_read_allow_uppercase () { $read_function_allow_uppercase lower="" for word in $user; do - if [ ! "${word::1}" = "-" ]; then # this check is done so ssh arguments are not made into lower case - word="$(sed -e 'y/QWERTYUIOPASDFGHJKLZXCVBNM/qwertyuiopasdfghjklzxcvbnm/' <<< "${word}")" + if [ ! "${word%%-*}" = "" ]; then # This check is done so SSH arguments are not made into lower case + word="$(echo "${word}" | sed -e 'y/QWERTYUIOPASDFGHJKLZXCVBNM/qwertyuiopasdfghjklzxcvbnm/')" fi lower="${lower} ${word}" done - lower="${lower:1}" + lower="${lower# *}" if [ ! "${lower}" = "${user}" ]; then #stty olcuc ## Uncomment this if you want to go old-school Unix, too bad ## it will break colours and only uppercases ASCII letters. diff --git a/gotrc-examples/commands b/gotrc-examples/commands index 1a98b07..6c382bf 100644 --- a/gotrc-examples/commands +++ b/gotrc-examples/commands @@ -8,7 +8,7 @@ login_function=_login_commands function _login_commands { - if [ "${user::1}" = "+" ]; then + if [ "${user%%+*}" = "" ]; then if [ "${user}" = "+shutdown" ]; then shutdown -h now elif [ "${user}" = "+reboot" ]; then diff --git a/gotrc-examples/issue-file b/gotrc-examples/issue-file index 85cc442..9f973e8 100644 --- a/gotrc-examples/issue-file +++ b/gotrc-examples/issue-file @@ -4,7 +4,7 @@ # only partially implemented, but also extended -function _display +_display () { python3 <<EOF buf = "\\033[H\\033[2J" diff --git a/gotrc-examples/lower-left-ponysay b/gotrc-examples/lower-left-ponysay index 563790d..686535a 100644 --- a/gotrc-examples/lower-left-ponysay +++ b/gotrc-examples/lower-left-ponysay @@ -7,14 +7,15 @@ function _display { - PALETTE=$'\e]P0020840\e]P1CD656C\e]P232A679\e]P3CCAD47\e]P42495BE\e]P5A46EB0\e]P600A09F\e]P7D3D7CF\e]P8555753\e]P9EB5E6A\e]PA0EC287\e]PBF2CA38\e]PC00ACE0\e]PDC473D1\e]PE00C3C7\e]PFEEEEEE' + PALETTE=$(echo -e '\e]P0020840\e]P1CD656C\e]P232A679\e]P3CCAD47\e]P42495BE\e]P5A46EB0\e]P600A09F\e]P7D3D7CF\e]P8555753\e]P9EB5E6A\e]PA0EC287\e]PBF2CA38\e]PC00ACE0\e]PDC473D1\e]PE00C3C7\e]PFEEEEEE') echo -n "${PALETTE}" echo -en '\e[H\e[2J\e[?8c' pony="$(PONYSAY_SHELL_LINES=5 PONYSAY_KMS_PALETTE="${PALETTE}" ponysay -o <&2)" - lines=$(wc -l <<< "${pony}") + lines=$(echo "${pony}" | wc -l) height=$(stty size | cut -d ' ' -f 1) - echo -n $'\e['"$(( $height - $lines + 1 ));1H$(sed -e 's:\x1b\[H\x1b\[2J::' <<< "${pony}")${PALETTE}"$'\e[H' - echo -e "\e[${ANSI_COLOR}m${NAME} (${tty})\e[00m" + echo -en $'\e['"$(( $height - $lines + 1 ));1H" + echo -n "$(echo "${pony}" | sed -e 's:\x1b\[H\x1b\[2J::')${PALETTE}" + echo -e "\e[H\e[${ANSI_COLOR}m${NAME} (${tty})\e[00m" echo echo -n 'Login: ' } diff --git a/gotrc-examples/no-empty-user b/gotrc-examples/no-empty-user index f398f65..f218c0f 100644 --- a/gotrc-examples/no-empty-user +++ b/gotrc-examples/no-empty-user @@ -6,7 +6,7 @@ read_function_no_empty_user=$read_function read_function=_read_no_empty_user -function _read_no_empty_user +_read_no_empty_user () { $read_function_no_empty_user if [ "${lower}" = "" ]; then |
