From 5d2b454f246c6d11ff9cf26839017a9950a831b2 Mon Sep 17 00:00:00 2001 From: Marco Raber Date: Thu, 28 Oct 2021 16:33:13 +0200 Subject: [PATCH] default handling on lookup in port_association file --- setup.sh | 2 +- sshin | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/setup.sh b/setup.sh index 8c4e48f..42f931f 100644 --- a/setup.sh +++ b/setup.sh @@ -1,3 +1,3 @@ mkdir ~/.local/share/sshin -cp port_association ~/.local/share/sshin/ +[[ -e ~/.local/share/sshin/port_association ]] || cp port_association ~/.local/share/sshin/ cp sshin ~/.local/bin || echo "Error in copying executable to ~/.local/bin" && echo "Run: sudo cp sshin /usr/bin/" diff --git a/sshin b/sshin index 3bffc60..f69d767 100755 --- a/sshin +++ b/sshin @@ -21,7 +21,9 @@ if [[ $1 =~ $re ]] then command="${command}192.168.1.$1" else - port=$(grep $1 ~/.local/share/sshin/port_association | awk '{print $NF}') && command="${command}$1 -p $port" + port=$(grep $1 ~/.local/share/sshin/port_association | awk '{print $NF}') + command="${command}$1" + [[ -n $port ]] && command="${command} -p $port" fi -#echo $command +echo $command $command