add shopts for bash and fix hostname shortening for ips

This commit is contained in:
Uwe Werler 2019-05-24 16:00:13 +00:00
parent 0af3096556
commit 7fe18fec4d

6
ssh.sh
View File

@ -58,17 +58,18 @@ _checkname(){
case $_l in hostname)
# make stupid check if hostname is an IP
[[ ${SHELL} == /bin/bash ]] && shopt -s extglob
_ip=${2##+([0-9]).+([0-9]).+([0-9]).+([0-9])}
_ip=${_ip##+([0-9a-f]):+([0-9a-f]):+([0-9a-f]):*([0-9a-f:]):+([0-9a-f])}
if [[ -z ${_ip} ]]; then
_host=$(dig +short -x ${2})
[[ -n "${_host}" ]] && _host=${_host} || _host=${2}
[[ -n "${_host}" ]] && _host=${_host%%.*} || _host=${2}
else
_host=${2}
_host=${2%%.*}
fi
break
;;
@ -112,7 +113,6 @@ _readstyle() {
_setpane(){
local _title=${1} _style
_title=${_title%%.*}
[[ -z ${_title} ]] && _title=$(hostname -s)