From 181f0b74c660b32f0847fc2aa20529d248b896d0 Mon Sep 17 00:00:00 2001 From: Daniel Robbins Date: Tue, 21 Jul 2009 23:40:12 -0600 Subject: [PATCH] replace "tty" command w. "test -t 0", MacOS X color fix I'm optimistic that most UNIX and UNIX-like systems support "test -t 0", but the possibility exists that some systems will not like this. This fix allows color to work in MacOS X 10.5.7. For some reason, the tty command is flaky when run from ~/.bash_profile and will report no tty. Didn't quite figure it out. But I did isolate it to this conditional, and verified that "test -t 0" (which is recommended as an alternative in the MacOS X "tty" man page) does get MacOS X color working again. --- keychain.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/keychain.sh b/keychain.sh index 7c8c956..8f33440 100755 --- a/keychain.sh +++ b/keychain.sh @@ -357,7 +357,7 @@ findpids() { # Try systems where we know what to do first case "$OSTYPE" in - AIX|*bsd*|*BSD*|CYGWIN|darwin*|Linux|linux-gnu|OSF1) + AIX|*bsd*|*BSD*|CYGWIN|darwin*|Linux|linux-gnu|OSF3) fp_psout=`ps x 2>/dev/null` ;; # BSD syntax HP-UX) fp_psout=`ps -u $me 2>/dev/null` ;; # SysV syntax @@ -1261,7 +1261,7 @@ fi # Don't use color if there's no terminal on stdout if [ -n "$OFF" ]; then - tty <&1 >/dev/null 2>&1 || unset BLUE CYAN GREEN OFF RED + test -t 0 || unset BLUE CYAN GREEN OFF RED fi # versinfo uses qprint, which honors --quiet