Commit 00b21d5a authored by Christian Höltje's avatar Christian Höltje Committed by Christian Höltje
Browse files

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
parent 207b6a1e
......@@ -38,9 +38,9 @@ for plugin ($plugins); do
done
# Figure out the SHORT hostname
if [ -n "$commands[scutil]" ]; then
# OS X
SHORT_HOST=$(scutil --get ComputerName)
if [[ "$OSTYPE" = darwin* ]]; then
# OS X's $HOST changes with dhcp, etc. Use ComputerName if possible.
SHORT_HOST=$(scutil --get ComputerName 2>/dev/null) || SHORT_HOST=${HOST/.*/}
else
SHORT_HOST=${HOST/.*/}
fi
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment