From 7fe18fec4d076ea26d96612b776d1eee2a757009 Mon Sep 17 00:00:00 2001 From: Uwe Werler Date: Fri, 24 May 2019 16:00:13 +0000 Subject: [PATCH] add shopts for bash and fix hostname shortening for ips --- ssh.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ssh.sh b/ssh.sh index b997af7..e8fb6f6 100644 --- a/ssh.sh +++ b/ssh.sh @@ -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)