From 44d9f6eebd14e150b6f17a4cdb7f25470b092485 Mon Sep 17 00:00:00 2001 From: Teal Dulcet Date: Thu, 21 Dec 2023 08:06:26 -0800 Subject: [PATCH] Fixed SC2236: Use -n instead of ! -z. --- setup/nextcloud.sh | 2 +- setup/questions.sh | 6 +++--- setup/system.sh | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/setup/nextcloud.sh b/setup/nextcloud.sh index 446085c2..1fb19ade 100755 --- a/setup/nextcloud.sh +++ b/setup/nextcloud.sh @@ -194,7 +194,7 @@ if [ ! -d /usr/local/lib/owncloud/ ] || [[ ! ${CURRENT_NEXTCLOUD_VER} =~ ^$nextc fi # If ownCloud or Nextcloud was previously installed.... - if [ ! -z "${CURRENT_NEXTCLOUD_VER}" ]; then + if [ -n "${CURRENT_NEXTCLOUD_VER}" ]; then # Database migrations from ownCloud are no longer possible because ownCloud cannot be run under # PHP 7. diff --git a/setup/questions.sh b/setup/questions.sh index 2144d51f..dd62d44a 100644 --- a/setup/questions.sh +++ b/setup/questions.sh @@ -93,7 +93,7 @@ if [ -z "${PUBLIC_IP:-}" ]; then # On the first run, if we got an answer from the Internet then don't # ask the user. - if [[ -z "${DEFAULT_PUBLIC_IP:-}" && ! -z "$GUESSED_IP" ]]; then + if [[ -z "${DEFAULT_PUBLIC_IP:-}" && -n "$GUESSED_IP" ]]; then PUBLIC_IP=$GUESSED_IP # Otherwise on the first run at least provide a default. @@ -126,7 +126,7 @@ if [ -z "${PUBLIC_IPV6:-}" ]; then # Ask the Internet. GUESSED_IP=$(get_publicip_from_web_service 6) MATCHED=0 - if [[ -z "${DEFAULT_PUBLIC_IPV6:-}" && ! -z "$GUESSED_IP" ]]; then + if [[ -z "${DEFAULT_PUBLIC_IPV6:-}" && -n "$GUESSED_IP" ]]; then PUBLIC_IPV6=$GUESSED_IP elif [[ "${DEFAULT_PUBLIC_IPV6:-}" == "$GUESSED_IP" ]]; then # No IPv6 entered and machine seems to have none, or what @@ -198,7 +198,7 @@ fi echo echo "Primary Hostname: $PRIMARY_HOSTNAME" echo "Public IP Address: $PUBLIC_IP" -if [ ! -z "$PUBLIC_IPV6" ]; then +if [ -n "$PUBLIC_IPV6" ]; then echo "Public IPv6 Address: $PUBLIC_IPV6" fi if [ "$PRIVATE_IP" != "$PUBLIC_IP" ]; then diff --git a/setup/system.sh b/setup/system.sh index 59a3fe8e..b49f0120 100755 --- a/setup/system.sh +++ b/setup/system.sh @@ -165,7 +165,7 @@ fi # not likely the user will want to change this, so we only ask on first # setup. if [ -z "${NONINTERACTIVE:-}" ]; then - if [ ! -f /etc/timezone ] || [ ! -z "${FIRST_TIME_SETUP:-}" ]; then + if [ ! -f /etc/timezone ] || [ -n "${FIRST_TIME_SETUP:-}" ]; then # If the file is missing or this is the user's first time running # Mail-in-a-Box setup, run the interactive timezone configuration # tool. @@ -271,7 +271,7 @@ if [ -z "${DISABLE_FIREWALL:-}" ]; then # settings, find the port it is supposedly running on, and open that port #NODOC # too. #NODOC SSH_PORT=$(sshd -T 2>/dev/null | grep "^port " | sed "s/port //") #NODOC - if [ ! -z "$SSH_PORT" ]; then + if [ -n "$SSH_PORT" ]; then if [ "$SSH_PORT" != "22" ]; then echo Opening alternate SSH port "$SSH_PORT". #NODOC