Skip to content

Commit

Permalink
replace "tty" command w. "test -t 0", MacOS X color fix
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
danielrobbins committed Jul 22, 2009
1 parent 66e2d99 commit 181f0b7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions keychain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 181f0b7

Please sign in to comment.