sethost: If no host options are specified, try to guess

This commit is contained in:
YAMAMOTO Takashi 2020-02-06 16:16:53 +09:00 committed by Xiang Xiao
parent 4c0bc308cc
commit afd03f5a7e
1 changed files with 28 additions and 2 deletions

View File

@ -34,8 +34,8 @@
progname=$0
debug=n
host=linux
wenv=cygwin
host=
wenv=
unset configfile
function showusage {
@ -94,6 +94,32 @@ while [ ! -z "$1" ]; do
shift
done
# If the host was not explicitly given, try to guess.
# Examples of "uname -s" outputs:
# macOS: Darwin
# Cygwin: CYGWIN_NT-10.0-WOW
# Linux: Linux
# MSYS: MINGW32_NT-6.2
if [ -z "$host" ]; then
case $(uname -s) in
Darwin)
host=macos
;;
CYGWIN*)
host=windows
wenv=cygwin
;;
MINGW32*)
host=windows
wenv=msys
;;
*)
# Assume linux as a fallback
host=linux
;;
esac
fi
if [ ! -z "$1" ]; then
echo "ERROR: Garbage at the end of line"
showusage