From 56aac8fbb6387774b6cf930028d0773bad2678f9 Mon Sep 17 00:00:00 2001 From: Joel Kuzmarski Date: Tue, 23 Aug 2016 10:31:34 -0500 Subject: [PATCH] Better TTY logic for zlogin and zlogout --- runcoms/zlogin | 11 +++++++---- runcoms/zlogout | 5 +++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/runcoms/zlogin b/runcoms/zlogin index 30549f33..16fae45e 100644 --- a/runcoms/zlogin +++ b/runcoms/zlogin @@ -14,10 +14,13 @@ fi } &! -# Print a random, hopefully interesting, adage. -if (( $+commands[fortune] )); then - if [[ -t 0 || -t 1 ]]; then +# Execute code only if STDERR is bound to a TTY. +[[ -o INTERACTIVE && -t 2 ]] && { + + # Print a random, hopefully interesting, adage. + if (( $+commands[fortune] )); then fortune -s print fi -fi + +} >&2 diff --git a/runcoms/zlogout b/runcoms/zlogout index 7c27e885..56b6b551 100644 --- a/runcoms/zlogout +++ b/runcoms/zlogout @@ -5,9 +5,14 @@ # Sorin Ionescu # +# Execute code only if STDERR is bound to a TTY. +[[ -o INTERACTIVE && -t 2 ]] && { + # Print the message. cat <<-EOF Thank you. Come again! -- Dr. Apu Nahasapeemapetilon EOF + +} >&2