minor updates
[automated-distro-installer] / chost
1 #!/bin/bash
2 # Copyright (C) 2016 Ian Kelling
3
4 # chost: get canonical hostname
5
6 set -eE -o pipefail
7 trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
8
9 host=$1
10 addr=$(host $host | sed -rn 's/^\S+ has address //p;T;q')
11 h=$(host $addr)
12 h=${h##* }
13 echo ${h%%.*}