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
Trust but verify 'scutil' to return ComputerName #2743
Conversation
ping? |
👍 |
SHORT_HOST=$(scutil --get ComputerName) | ||
if [[ "$OSTYPE" = darwin* ]]; then | ||
# OS X's $HOST changes with dhcp, etc. Use ComputerName if possible. | ||
SHORT_HOST=$(/usr/sbin/scutil --get ComputerName 2>/dev/null) || SHORT_HOST=${HOST/.*/} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
scutil
should continue being used without absolute path. Also, on #2183 they use `$(hostname -s)', is that better than using $HOST?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are three reasons to continue to use $HOST
:
- Even if
$OSTYPE
equalsdarwin*
that doesn't mean they are running a full OS X environment (e.g. just running the darwin kernel on a bsd or gnu system).hostname -s
doesn't work on all unixes. $HOST
is faster since it doesn't have to fork/exec.- It matches what happens on non-OSX systems.
Apparently, it is possible to set up a Mac such that `scutil --get ComputerName` hasn't been set. This change checks if that fails and falls back to the original mechanism. Closes ohmyzsh#2155 Closes ohmyzsh#2183
I removed the |
Perfect, I support this change (bonus points for using |
If you want more @mcornella and @ncanceill -- Should I resubmit this and #2744 to https://github.com/ncanceill/oh-my-zsh/tree/easymerge ? |
/cc @robbyrussell |
Trust but verify 'scutil' to return ComputerName
Apparently, it is possible to set up a Mac such that
scutil --get ComputerName
hasn't been set.This change checks if that fails and falls back to the original mechanism.
Closes #2155
Closes #2183