Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Terminals.hascolor checking on FreeBSD #20676

Merged
merged 1 commit into from
Feb 22, 2017

Conversation

iblislin
Copy link
Member

(not sure why setaf not works :p

@tkelman tkelman added system:freebsd Affects only FreeBSD REPL Julia's REPL (Read Eval Print Loop) labels Feb 19, 2017
@@ -156,7 +156,11 @@ else
function hascolor(t::TTYTerminal)
startswith(t.term_type, "xterm") && return true
try
return success(`tput setaf 0`)
@static if Sys.KERNEL == :FreeBSD
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this doesn't work for FreeBSD, I have a feeling it wouldn't work for Dragonfly and others, so this might be better as

@static if is_bsd() && !is_apple()

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's only for FreeBSD.

I tried OpenBSD, it's more complicate:

# TERM=rxvt tput setaf 1 && echo 'work'  
work
# TERM=rxvt-256color tput setaf 1 && echo 'work'
tput: not enough arguments (3) for capability `setaf'
# TERM=rxvt-256color tput setaf 1 0 0 && echo 'work'
work
# TERM=screen tput setaf 1 && echo 'work'             
work
# TERM=screen-256color tput setaf 1 && echo 'work'    
tput: not enough arguments (3) for capability `setaf'
# TERM=screen-256color tput setaf 1 0 0 && echo 'work'
work
# uname -a                                                                     
OpenBSD obsd.my.domain 6.0 GENERIC.MP#2319 amd64

In case of NetBSD, both tput AF and tput setaf work:

# uname -a
NetBSD  7.0.2 NetBSD 7.0.2 (GENERIC.201610210724Z) amd64
# TERM=rxvt tput setaf 1 && echo 'work'
work
# TERM=rxvt-256color tput setaf 1 && echo 'work'
work
# TERM=screen tput setaf 1 && echo 'work'
work
# TERM=screen-256color tput setaf 1 && echo 'work'
work
# TERM=screen-256color tput AF 1 && echo 'work'
work

In case of DragonFly... seems subtle. tput setaf not work, and tput AF only works on non -256color term type.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, thanks for checking. I think what you have here is fine then.

@ararslan
Copy link
Member

not sure why setaf not works

FreeBSD uses Termcap for its attributes rather than Terminfo; AF is the Termcap version of Terminfo's setaf.

@ararslan ararslan merged commit f3961b9 into JuliaLang:master Feb 22, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
REPL Julia's REPL (Read Eval Print Loop) system:freebsd Affects only FreeBSD
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants