From 27a55e2623884c72a0d4e997e586aaccbaabdf72 Mon Sep 17 00:00:00 2001 From: Martin Winkler Date: Mon, 4 Jul 2022 11:46:48 +0200 Subject: [PATCH] ssh - fix unbound variable error --- seqs/ssh.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/seqs/ssh.sh b/seqs/ssh.sh index de5c9a4..f4731db 100755 --- a/seqs/ssh.sh +++ b/seqs/ssh.sh @@ -78,10 +78,10 @@ step_10_info() { step_10_alias() { echo "sendlist"; } step_10() { shift - aList=$1 - aHost=$2 + aList=${1:-} + aHost=${2:-} # Set port only if not empty - if [ ! -z "$3" ]; then + if [ -n "${3:-}" ]; then aPort=$3 fi parseList $aList @@ -113,8 +113,8 @@ step_10() { parseList() { local errorMsg="" - if [ -z "$1" ] || [ ! -f "$1" ]; then - if [ -z "$1" ]; then + if [ -z "${1:-}" ] || [ ! -f "${1:-}" ]; then + if [ -z "${1:-}" ]; then error -e "No Command list found" else error -e "Command list not found: $1" @@ -132,7 +132,7 @@ parseList() { return 1 fi - info "Parsing $(realpath $1) ..." + info "Parsing $(realpath -- "${1:-}") ..." local line=1 # Working loop without ssh "stealing standard input" by # https://unix.stackexchange.com/questions/24260/reading-lines-from-a-file-with-bash-for-vs-while