add shopts for bash and fix hostname shortening for ips
This commit is contained in:
parent
0af3096556
commit
7fe18fec4d
6
ssh.sh
6
ssh.sh
@ -58,17 +58,18 @@ _checkname(){
|
|||||||
case $_l in hostname)
|
case $_l in hostname)
|
||||||
|
|
||||||
# make stupid check if hostname is an IP
|
# 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=${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])}
|
_ip=${_ip##+([0-9a-f]):+([0-9a-f]):+([0-9a-f]):*([0-9a-f:]):+([0-9a-f])}
|
||||||
|
|
||||||
if [[ -z ${_ip} ]]; then
|
if [[ -z ${_ip} ]]; then
|
||||||
|
|
||||||
_host=$(dig +short -x ${2})
|
_host=$(dig +short -x ${2})
|
||||||
[[ -n "${_host}" ]] && _host=${_host} || _host=${2}
|
[[ -n "${_host}" ]] && _host=${_host%%.*} || _host=${2}
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
||||||
_host=${2}
|
_host=${2%%.*}
|
||||||
fi
|
fi
|
||||||
break
|
break
|
||||||
;;
|
;;
|
||||||
@ -112,7 +113,6 @@ _readstyle() {
|
|||||||
_setpane(){
|
_setpane(){
|
||||||
|
|
||||||
local _title=${1} _style
|
local _title=${1} _style
|
||||||
_title=${_title%%.*}
|
|
||||||
|
|
||||||
[[ -z ${_title} ]] && _title=$(hostname -s)
|
[[ -z ${_title} ]] && _title=$(hostname -s)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user