From 4f8c1b5388bccc5383fa826751fb8b880370a3ac Mon Sep 17 00:00:00 2001 From: Martin Winkler Date: Thu, 2 Jun 2022 16:08:07 +0200 Subject: [PATCH] Fix unbound variable errors --- seqs/backup.sh | 11 +++++------ seqs/debianrpi.sh | 4 ++-- seqs/downloader.sh | 5 +++-- seqs/ebackup.sh | 12 ++++++------ seqs/element-web.sh | 2 +- seqs/friendica.sh | 8 ++++---- seqs/ldap.sh | 6 +++--- seqs/mailserver.sh | 13 ++++++------- seqs/mayan-edms.sh | 8 ++++---- seqs/postfixadmin.sh | 21 +++++++++++---------- seqs/raspberry.sh | 40 ++++++++++++++++++++-------------------- seqs/roundcube.sh | 2 +- seqs/snmp.sh | 4 ++-- seqs/ssh.sh | 2 +- seqs/torrentwatch.sh | 33 ++++++++++++++++----------------- 15 files changed, 85 insertions(+), 86 deletions(-) diff --git a/seqs/backup.sh b/seqs/backup.sh index 0fd0215..242ec98 100755 --- a/seqs/backup.sh +++ b/seqs/backup.sh @@ -54,21 +54,21 @@ step_3_info() { local tar="" local exc="[EXCLUDES...]" shift - if [ "$1" == "-t" ] ; then + if [ "${1:-}" == "-t" ] ; then opt=" -t " tar= shift fi - if [ ! -z "$1" ] ; then + if [ -n "${1:-}" ] ; then dir="$1" shift - if [ ! -z $tar ] && [ ! -z "$1" ] ; then + if [ -n $tar ] && [ -n "$1" ] ; then tar="$1" shift else tar="$BACKUP_TARGET" fi - if [ ! -z "$1" ] ; then + if [ -n "${1:-}" ] ; then exc="$@" else exc="[NO EXCLUDES]" @@ -83,7 +83,6 @@ step_3_info() { } step_3_alias() { echo "budir"; } step_3() { - local arg local configTarget=0 local noRemount=0 local buSource= @@ -93,7 +92,7 @@ step_3() { # don't use step number shift - for arg in "$@"; do + for _ in "$@"; do case "$1" in -t) configTarget=1 diff --git a/seqs/debianrpi.sh b/seqs/debianrpi.sh index 1d160d6..55b7d40 100755 --- a/seqs/debianrpi.sh +++ b/seqs/debianrpi.sh @@ -39,7 +39,7 @@ step_1() { SDDEV="$2" if [ -z "$1" ] && interactive ; then read -p "Provide image download url from $toolDownSite: " toolDownUrl - elif [ ! -z "$1" ] ; then + elif [ -n "${1:-}" ] ; then toolDownUrl="$1" else error -e "No image file provided for download" @@ -246,7 +246,7 @@ HDBOOT_EOF read_sd_dev() { local partExt="" - if [ ! -z "$1" ] ; then + if [ -n "${1:-}" ] ; then SDBOOT= SDROOT= SDROOTDEV= diff --git a/seqs/downloader.sh b/seqs/downloader.sh index 18273f0..f68f849 100755 --- a/seqs/downloader.sh +++ b/seqs/downloader.sh @@ -601,8 +601,9 @@ step_50() { } checkVpn() { - ip -br a | grep tun >>/dev/null 2>&1 - [ $? -eq 0 ] && warning "A VPN connection is possibly active. Consider deactivating it befor any apt operation." + if ip -br a | grep tun >>/dev/null 2>&1 ; then + [ $? -eq 0 ] && warning "A VPN connection is possibly active. Consider deactivating it befor any apt operation." + fi } readonly sqr_minVersion=16 diff --git a/seqs/ebackup.sh b/seqs/ebackup.sh index 5dce88a..c94b443 100755 --- a/seqs/ebackup.sh +++ b/seqs/ebackup.sh @@ -59,9 +59,9 @@ step_1() { return 1 fi - if [ ! -z "$1" ] && ( [ "$1" == "full" ] || [ "$1" == "incremental" ] ) ; then + if [ -n "${1:-}" ] && ( [ "$1" == "full" ] || [ "$1" == "incremental" ] ) ; then dupArgs+=("$1") - elif [ ! -z "$1" ] ; then + elif [ -n "${1:-}" ] ; then echo " [W] $toolName command \"$1\" not recognized" return 1 fi @@ -155,7 +155,7 @@ step_7() { shift local ebuTarget="$EBU_TARGET" local dupCommand= - if [ ! -z "$1" ] ; then + if [ -n "${1:-}" ] ; then ebuTarget="$1" fi @@ -182,7 +182,7 @@ step_20_info() { [ ! -z "${1:-}" ] && ebuTarget="$1" if contextHelp; then echo "Status of (profile) [TARGET]" - elif [ ! -z "$1" ]; then + elif [ -n "${1:-}" ]; then echo "Status of target: $ebuTarget" else echo "Status of profile \"$seq_profileName\" target: $ebuTarget" @@ -192,7 +192,7 @@ step_20_alias() { echo 'status'; } step_20() { shift local ebuTarget="$EBU_TARGET" - if [ ! -z "$1" ] ; then + if [ -n "${1:-}" ] ; then ebuTarget="$1" fi @@ -205,7 +205,7 @@ step_22_alias() { echo 'list'; } step_22() { shift local ebuTarget="$EBU_TARGET" - if [ ! -z "$1" ] ; then + if [ -n "${1:-}" ] ; then ebuTarget="$1" fi diff --git a/seqs/element-web.sh b/seqs/element-web.sh index 7778cc1..328b700 100755 --- a/seqs/element-web.sh +++ b/seqs/element-web.sh @@ -60,7 +60,7 @@ step_20() { if [ ! -z $ELEMENT_WEB_BACKUP ] ; then exe mkdir -p "$ELEMENT_WEB_BACKUP" fi - if [ ! -z $1 ] ; then + if [ -n "${1:-}" ] ; then tempRoot="$1" else tempRoot="$ELEMENT_WEB_LOC" diff --git a/seqs/friendica.sh b/seqs/friendica.sh index e4a7f08..d325e0a 100755 --- a/seqs/friendica.sh +++ b/seqs/friendica.sh @@ -35,10 +35,10 @@ step_20() { error -e "No configuration file found" return 1 fi - if [ ! -z $FR_BACKUP ] ; then + if [ -n "$FR_BACKUP" ] ; then exe mkdir -p "$FR_BACKUP" fi - if [ ! -z "$1" ] ; then + if [ -n "${1:-}" ] ; then tempRoot="$1" else tempRoot="$FR_LOC" @@ -61,7 +61,7 @@ step_20() { step_22_info() { shift - if [ -z $1 ] ; then + if [ -z "${1:-}" ] ; then echo -n "Get latest version from github" if ! contextHelp ; then echo ": $(curl --silent "$latestUrl" | grep -Po '"tag_name": "\K.*?(?=")')" @@ -76,7 +76,7 @@ step_22_alias() { echo "upgrade"; } step_22() { shift # don't need step number local latestVersion= - if [ ! -z $1 ] ; then + if [ -n "${1:-}" ] ; then latestVersion="$1" else latestVersion=$(curl --silent "$latestUrl" | grep -Po '"tag_name": "\K.*?(?=")') diff --git a/seqs/ldap.sh b/seqs/ldap.sh index f356a9d..de93beb 100755 --- a/seqs/ldap.sh +++ b/seqs/ldap.sh @@ -218,7 +218,7 @@ step_103_info() { echo "(re)Set passwort for "; } step_103_alias() { echo "passwd"; } step_103() { shift - if [ ! -z $1 ] ; then + if [ -n "${1:-}" ] ; then echo " [I] Password operation for $1" userId="$1" elif [ ! -z $userId ] ; then @@ -234,7 +234,7 @@ step_105_info() { echo "Adding to existing group "; } step_105_alias() { echo "user2group"; } step_105() { shift - if [ ! -z $1 ] ; then + if [ -n "${1:-}" ] ; then userId="$1" echo " [I] User operation for $userId" elif [ ! -z $userId ] ; then @@ -269,7 +269,7 @@ step_107_info() { echo "Removing from existing group "; } step_107_alias() { echo "rmusergroup"; } step_107() { shift - if [ ! -z $1 ] ; then + if [ -n "${1:-}" ] ; then userId="$1" echo " [I] User operation for $userId" elif [ ! -z $userId ] ; then diff --git a/seqs/mailserver.sh b/seqs/mailserver.sh index 9fc244a..53e2b8d 100755 --- a/seqs/mailserver.sh +++ b/seqs/mailserver.sh @@ -31,7 +31,7 @@ seq_config() { initSeqConfig "$CONFIG_FILE_NAME" "$CONFIG_FILE_TEMPLATE" if [ $? -eq 0 ] ; then CONFIG=1 - info " Domain: $MAS_DOMAIN" + info " Domain: ${MAS_DOMAIN:-}" elif [ $? -eq 1 ] ; then # Config $CONFIG_FILE_NAME created. Needs modification first dry || return -1 @@ -415,20 +415,19 @@ step_100_info() { step_100_alias() { echo "test"; } step_100() { shift - local arg local fromAdr local toAdr="postmaster@$MAS_DOMAIN" local asUser= - for arg in "$@" ; do + for _ in "$@" ; do case "$1" in -f) shift - fromAdr="-f $1 " + fromAdr="-f ${1:-} " shift ;; -u) shift - asUser="sudo -u $1 " + asUser="sudo -u ${1:-} " shift ;; *) @@ -436,7 +435,7 @@ step_100() { ;; esac done - if [ ! -z $1 ] ; then + if [ -n "${1:-}" ] ; then toAdr="$1" fi exe ${asUser}sh -c "echo \"Subject: Test from Postfix\nIt is \$(date)\n\nGreetings \$(whoami)\" | sendmail ${fromAdr}$toAdr" @@ -456,7 +455,7 @@ step_104_alias() { echo "delqueue"; } step_104() { shift local msgId="ALL" - if [ ! -z $1 ] ; then + if [ -n "${1:-}" ] ; then msgId="$1" fi exe postsuper -d "$msgId" diff --git a/seqs/mayan-edms.sh b/seqs/mayan-edms.sh index 7eaef2b..4667cbd 100755 --- a/seqs/mayan-edms.sh +++ b/seqs/mayan-edms.sh @@ -25,9 +25,9 @@ seq_config() { initSeqConfig "$CONFIG_FILE_NAME" "$CONFIG_FILE_TEMPLATE" if [ $? -eq 0 ] ; then CONFIG=1 - postgresDb="$MAYAN_DB" - postgresUser="$MAYAN_DBUSER" - postgresPass="$MAYAN_DBPASS" + postgresDb="${MAYAN_DB:-}" + postgresUser="${MAYAN_DBUSER:-}" + postgresPass="${MAYAN_DBPASS:-}" else # End if no configuration file exists dry || return -1 @@ -223,7 +223,7 @@ readDatabaseInfos() { # Needs readDatabaseInfos() to execute some commands toolScript() { - if [ ! -z "$1" ] ; then + if [ -n "${1:-}" ] ; then readDatabaseInfos fi diff --git a/seqs/postfixadmin.sh b/seqs/postfixadmin.sh index 883dc7c..1b8c317 100755 --- a/seqs/postfixadmin.sh +++ b/seqs/postfixadmin.sh @@ -1,7 +1,7 @@ #!/bin/bash toolName=postfixadmin -toolPhpDeps='php${PFA_PHP_VERSION}-fpm php${PFA_PHP_VERSION}-imap php${PFA_PHP_VERSION}-mbstring php${PFA_PHP_VERSION}-mysql php${PFA_PHP_VERSION}-json php${PFA_PHP_VERSION}-curl php${PFA_PHP_VERSION}-zip php${PFA_PHP_VERSION}-xml php${PFA_PHP_VERSION}-bz2 php${PFA_PHP_VERSION}-intl php${PFA_PHP_VERSION}-gmp' +toolPhpDeps='php${PFA_PHP_VERSION:-}-fpm php${PFA_PHP_VERSION:-}-imap php${PFA_PHP_VERSION:-}-mbstring php${PFA_PHP_VERSION:-}-mysql php${PFA_PHP_VERSION:-}-json php${PFA_PHP_VERSION:-}-curl php${PFA_PHP_VERSION:-}-zip php${PFA_PHP_VERSION:-}-xml php${PFA_PHP_VERSION:-}-bz2 php${PFA_PHP_VERSION:-}-intl php${PFA_PHP_VERSION:-}-gmp' toolConfName="config.local.php" toolTemplates="templates_c" toolTemplatesLoc="$PFA_SRV_LOC/$toolTemplates" @@ -18,12 +18,13 @@ CONFIG_FILE_NAME="${toolName}.cfg" CONFIG_FILE_TEMPLATE="$WDIR/${CONFIG_FILE_NAME}.example" seq_config() { - initSeqConfig "$CONFIG_FILE_NAME" "$CONFIG_FILE_TEMPLATE" - if [ $? -eq 0 ] ; then - echo " ${toolName} path: ${PFA_WEB_LOC}" - echo " ${toolName} backup: ${PFA_BACKUP}" - echo " php Version: ${PFA_PHP_VERSION}" + if initSeqConfig "$CONFIG_FILE_NAME" "$CONFIG_FILE_TEMPLATE" ; then + info "${toolName} path: ${PFA_WEB_LOC:-}" + info -a "${toolName} backup: ${PFA_BACKUP:-}" + info -a " php Version: ${PFA_PHP_VERSION:-}" CONFIG=1 + else + dry || return 1 fi } @@ -45,7 +46,7 @@ step_1() { exe apt install $localDeps $aptOpt } -step_2_info() { echo "Install $toolName to $PFA_SRV_LOC"; } +step_2_info() { echo "Install $toolName to ${PFA_SRV_LOC:-}"; } step_2() { step upgrade } @@ -149,7 +150,7 @@ step_18() { shift local isInstalled= local latestVersion= - if [ ! -z $1 ] ; then + if [ -n "${1:-}" ] ; then latestVersion="$1" else latestVersion=$(curl --silent "$latestUrl" | grep -Po '"tag_name": "postfixadmin-\K.*?(?=")') @@ -186,7 +187,7 @@ step_20() { if [ ! -z $PFA_BACKUP ] ; then exe mkdir -p "$PFA_BACKUP" fi - if [ ! -z $1 ] ; then + if [ -n "${1:-}" ] ; then tempRoot="$1" else tempRoot="$PFA_SRV_LOC" @@ -219,7 +220,7 @@ step_22_alias() { echo "upgrade"; } step_22() { shift # don't need step number local latestVersion= - if [ ! -z $1 ] ; then + if [ -n "${1:-}" ] ; then latestVersion="$1" else latestVersion=$(curl --silent "$latestUrl" | grep -Po '"tag_name": "postfixadmin-\K.*?(?=")') diff --git a/seqs/raspberry.sh b/seqs/raspberry.sh index 35b4e8d..50a10ea 100755 --- a/seqs/raspberry.sh +++ b/seqs/raspberry.sh @@ -55,10 +55,10 @@ HDSWAPPUUID= evalArgs() { local argCount=0 - for arg in "$@"; do + for _ in "$@"; do case "$1" in -a|--arch) - if [ ! -z "$2" ]; then + if [ -n "${2:-}" ]; then PIARCH="$2" ((argCount+=2)) else @@ -115,7 +115,7 @@ step_2_info() { echoinfoArgs "[OPTIONS] [SD CARD DEVICE]" echo "Write Raspberry Pi OS image to SD card" echoinfo "This operation will delete all data previously on the SD card!" - contextExe && [ ! -z $1 ] && echoinfo " [SD CARD DEVICE]: $1" + contextExe && [ -n "${1:-}" ] && echoinfo " [SD CARD DEVICE]: $1" } step_2_alias() { echo "writesd"; } step_2() { @@ -134,7 +134,7 @@ step_2() { endReturn -o 1 "No root" fi - read_sd_dev "$1" + read_sd_dev "${1:-}" # check if device was confirmed if [ $? -ne 0 ] ; then endReturn -o 1 "SD card device not found" @@ -162,14 +162,14 @@ step_3_info() { echoinfoArgs "[SD CARD DEVICE]" echo "Prepare SD for first run" if contextExe; then - [ ! -z $1 ] && echoinfo " [SD CARD DEVICE]: $1" + [ -n "${1:-}" ] && echoinfo " [SD CARD DEVICE]: $1" fi } step_3() { # Shift away args shift; local lArgs=( "$@" ); evalArgs "${lArgs[@]}"; shift $? - if [ -z $1 ] && [ ! -z $SDDEV ] ; then + if [ -z "${1:-}" ] && [ -n "${SDDEV:-}" ] ; then if quiet ; then answer="n" else @@ -188,7 +188,7 @@ step_3() { esac fi - read_sd_dev "$1" + read_sd_dev "${1:-}" endReturn -o $? "SD card device not found" if [ ! -w "$SDBOOT" ] ; then @@ -213,8 +213,8 @@ step_4_info() { echoinfoArgs "[SD CARD DEVICE] [HD DEVICE]" echo "Prepare SD card to boot from hard disk" if contextExe; then - [ ! -z $1 ] && echoinfo " [SD CARD DEVICE]: $1" - [ ! -z $2 ] && echoinfo " [HD DEVICE]: $2" + [ -n "${1:-}" ] && echoinfo " [SD CARD DEVICE]: $1" + [ -n "${2:-}" ] && echoinfo " [HD DEVICE]: $2" fi } step_4_alias() { echo "hdboot"; } @@ -222,9 +222,9 @@ step_4() { # Shift away args shift; local lArgs=( "$@" ); evalArgs "${lArgs[@]}"; shift $? - read_sd_dev "$1" + read_sd_dev "${1:-}" endReturn -o $? "SD detection error $?" - read_hd_dev "$2" + read_hd_dev "${2:-}" endReturn -o $? "HD detection error" echo " [I] SD: $SDDEV" echo " $SDBOOT [$SDBOOTPUUID]" @@ -285,8 +285,8 @@ step_5_info() { echo "Prepare HD for boot (TODO)" if contextExe; then - [ ! -z $1 ] && echoinfo " [SD CARD DEVICE]: $1" - [ ! -z $2 ] && echoinfo " [HD DEVICE]: $2" + [ -n "${1:-}" ] && echoinfo " [SD CARD DEVICE]: $1" + [ -n "${2:-}" ] && echoinfo " [HD DEVICE]: $2" fi } step_5() { @@ -296,10 +296,10 @@ step_5() { #TODO error -e "Not ready yet...TODO" #return 1 - read_sd_dev "$1" + read_sd_dev "${1:-}" endReturn -o $? "SD detection error $?" - read_hd_dev "$2" + read_hd_dev "${2:-}" endReturn -o $? "HD detection error" echo " [I] SD: $SDDEV" echo " $SDBOOT [$SDBOOTPUUID]" @@ -333,14 +333,14 @@ step_5() { read_sd_dev() { local partExt="" - if [ ! -z "$1" ] ; then + if [ -n "${1:-}" ] ; then SDBOOT= SDROOT= SDROOTDEV= SDROOTPUUID= SDBOOTPUUID= SDDEV="$1" - elif [ -z $SDDEV ] || [ ! -b "$SDDEV" ] ; then + elif [ -z "${SDDEV:-}" ] || [ ! -b "$SDDEV" ] ; then SDDEV= SDBOOT= SDROOT= @@ -385,7 +385,7 @@ SDBOOTPARTNO=1 SDROOTPARTNO=2 read_hd_dev() { - if [ ! -z "$1" ] ; then + if [ -n "${1:-}" ] ; then HDROOT= HDROOTPUUID= HDSWAPPUUID= @@ -447,7 +447,7 @@ step_22_info() { echoinfoArgs "[SD CARD DEVICE]"; echo "Resize second SD card pa step_22_alias() { echo "resizesd"; } step_22() { shift - read_sd_dev "$1" + read_sd_dev "${1:-}" if [ -z $SDDEV ] || [ "$SDDEV" = "" ] || [ "$SDROOT" == "/" ] ; then error -e "No SD found" return 1 @@ -570,7 +570,7 @@ tvserviceOffCmd="${tvserviceBin} -o'" # checkBootConfig [VALUE] checkBootConfig() { - [ -z "$1" ] && return 1 + [ -z "${1:-}" ] && return 1 local re_check="^[[:blank:]]*[^#]*${1}[[:blank:]]*=[[:blank:]]*$2" grep -rqE "$re_check" "$RPI_BOOT_CONFIG" diff --git a/seqs/roundcube.sh b/seqs/roundcube.sh index a9ee380..c3543ce 100755 --- a/seqs/roundcube.sh +++ b/seqs/roundcube.sh @@ -173,7 +173,7 @@ step_22() { shift # don't need step number local currentVersion= - if [ ! -z $1 ] ; then + if [ -n "${1:-}" ] ; then latestVersion="$1" else fetchLatestVersion diff --git a/seqs/snmp.sh b/seqs/snmp.sh index 7906719..838a94e 100755 --- a/seqs/snmp.sh +++ b/seqs/snmp.sh @@ -73,7 +73,7 @@ step_2() { addConf -a "$v3AuthEntry" "$v3AuthLoc" shift - if [ ! -z $1 ] && [ "$1" == "-s" ] ; then + if [ -n "${1:-}" ] && [ "$1" == "-s" ] ; then info "Stop after creating authentication config" exe service snmpd start return 0 @@ -109,7 +109,7 @@ step_5_alias() { echo "ufw"; } step_5() { shift local lInterface="eth0" - [ ! -z "$1" ] && lInterface="$1" + [ -n "${1:-}" ] && lInterface="$1" # Check if interface exists ip -br a | grep -E "^$lInterface" >>/dev/null 2>&1 endReturn -o $? "Interface $lInterface does not exist" diff --git a/seqs/ssh.sh b/seqs/ssh.sh index fe6c81e..de5c9a4 100755 --- a/seqs/ssh.sh +++ b/seqs/ssh.sh @@ -119,7 +119,7 @@ parseList() { else error -e "Command list not found: $1" fi - if [ ! -z "$1" ] && dry || interactive ; then + if [ -n "${1:-}" ] && dry || interactive ; then read -p " Create template there y/[n]? " answer case "$answer" in y|Y) diff --git a/seqs/torrentwatch.sh b/seqs/torrentwatch.sh index f820a2f..70f8369 100755 --- a/seqs/torrentwatch.sh +++ b/seqs/torrentwatch.sh @@ -19,36 +19,35 @@ CONFIG_FILE_NAME="${toolName}.cfg" CONFIG_FILE_TEMPLATE="$WDIR/${CONFIG_FILE_NAME}.example" seq_config() { - initSeqConfig "$CONFIG_FILE_NAME" "$CONFIG_FILE_TEMPLATE" - if [ $? -eq 0 ] ; then + if initSeqConfig "$CONFIG_FILE_NAME" "$CONFIG_FILE_TEMPLATE" ; then CONFIG=1 else dry || return 1 fi - toolConfigLoc=`eval echo "$TWXA_CONFIG_LOC"` + toolConfigLoc=`eval echo "${TWXA_CONFIG_LOC:-}"` toolConfig="$toolConfigLoc/config_cache/$toolConfigName" - toolHtmlLoc=`eval echo "$TWXA_HTML_LOC"` - toolBackupLoc=`eval echo "$TWXA_BACKUP_LOC"` - toolGitLoc=`eval echo "$TWXA_GIT_LOC"` - gitLibLoc=`eval echo "$TWXA_GIT_LOC/var/lib/torrentwatch-xa"` - gitHtmlLoc=`eval echo "$TWXA_GIT_LOC/var/www/html/torrentwatch-xa"` - echo " git: $toolGitLoc" - echo " config: $toolConfig" - echo " html: $toolHtmlLoc" - echo " backup: $toolBackupLoc" + toolHtmlLoc=`eval echo "${TWXA_HTML_LOC:-}"` + toolBackupLoc=`eval echo "${TWXA_BACKUP_LOC:-}"` + toolGitLoc=`eval echo "${TWXA_GIT_LOC:-}"` + gitLibLoc=`eval echo "${TWXA_GIT_LOC:-}/var/lib/torrentwatch-xa"` + gitHtmlLoc=`eval echo "${TWXA_GIT_LOC:-}/var/www/html/torrentwatch-xa"` + info " git: $toolGitLoc" + info -a "config: $toolConfig" + info -a " html: $toolHtmlLoc" + info -a "backup: $toolBackupLoc" } step_1_info() { echo "Install $toolName [VERSION]"; } step_1_alias() { echo "install"; } step_1() { shift - if [ ! -z $1 ] ; then + if [ -n "${1:-}" ] ; then toolVersion="$1" fi echo $toolConfig } -step_2_info() { echo "Setup git repository at $toolGitLoc [VERSION e.g. 1.4.1]"; } +step_2_info() { echo "Setup git repository at ${toolGitLoc:-} [VERSION e.g. 1.4.1]"; } step_2_alias() { echo "git"; } step_2() { shift @@ -60,7 +59,7 @@ step_2() { exe cd "$toolGitLoc" exe git pull fi - if [ ! -z $1 ] ; then + if [ -n "${1:-}" ] ; then toolVersion="$1" fi exe git checkout $toolVersion @@ -76,7 +75,7 @@ step_20() { fi local buType="all" - if [ ! -z $1 ] ; then + if [ -n "${1:-}" ] ; then buType="$1" fi local buDate=`date +%Y%m%d-%H%M%S` @@ -118,7 +117,7 @@ step_30_info() { echo "Upgrade $toolName [VERSION]"; } step_30_alias() { echo "upgrade"; } step_30() { shift - if [ ! -z $1 ] ; then + if [ -n "${1:-}" ] ; then toolVersion="$1" fi