Skip to content

Commit

Permalink
return false from hascolor if success(tput setaf 0) throws a julia …
Browse files Browse the repository at this point in the history
…exception
  • Loading branch information
tkelman committed Jan 14, 2016
1 parent 098ab43 commit 9723d52
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
9 changes: 8 additions & 1 deletion base/Terminals.jl
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,14 @@ start_reading(t::UnixTerminal) = start_reading(t.in_stream)
stop_reading(t::UnixTerminal) = stop_reading(t.in_stream)
eof(t::UnixTerminal) = eof(t.in_stream)

@unix_only hascolor(t::TTYTerminal) = (startswith(t.term_type, "xterm") || success(`tput setaf 0`))
@unix_only function hascolor(t::TTYTerminal)
startswith(t.term_type, "xterm") && return true
try
return success(`tput setaf 0`)
catch
return false
end
end
@windows_only hascolor(t::TTYTerminal) = true

end # module
3 changes: 0 additions & 3 deletions test/repl.jl
Original file line number Diff line number Diff line change
Expand Up @@ -347,9 +347,6 @@ let exename = joinpath(JULIA_HOME, Base.julia_exename())

# Test REPL in dumb mode
@unix_only begin
success(pipeline(`which tput`, DevNull)) || error("tput not found, " *
"install ncurses (or ncurses-bin or ncurses-utils) package")

const O_RDWR = Base.Filesystem.JL_O_RDWR
const O_NOCTTY = Base.Filesystem.JL_O_NOCTTY

Expand Down

0 comments on commit 9723d52

Please sign in to comment.