]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#1574] ${var+x}, ${var-x} changes
authorAndrei Pavel <andrei@isc.org>
Fri, 11 Dec 2020 14:23:27 +0000 (16:23 +0200)
committerAndrei Pavel <andrei@isc.org>
Mon, 14 Dec 2020 10:08:11 +0000 (12:08 +0200)
src/bin/admin/kea-admin.in
src/lib/testutils/dhcp_test_lib.sh.in
src/lib/util/tests/process_spawn_app.sh.in

index 57a0dba66f11d646b2deb0d9818ae1997ef4c644..206ca5e68d1e7e96856d85e246b9e337267cc28b 100644 (file)
@@ -709,7 +709,7 @@ fi
 shift
 
 # Ok, let's process parameters (if there are any)
-while [ -n "${1+x}" ]
+while test "${#}" -gt 0
 do
     option=${1}
     case ${option} in
index 67b20a167d68005005bace885e09a02d24cc8239..161bfa4d8aacec910da0d3db30ce14aa2438ed58 100644 (file)
@@ -192,6 +192,7 @@ test_finish() {
     else
         # Dump log file for debugging purposes if specified and exists.
         # Otherwise the code below would simply call cat.
+        # Use ${var+x} to test if ${var} is defined.
         if test -n "${LOG_FILE+x}" && test -s "${LOG_FILE}"; then
             printf 'Log file dump:\n'
             cat "${LOG_FILE}"
@@ -348,7 +349,8 @@ set_logger() {
 # PID file path is by default <kea-install-dir>/var/run/kea, but can be
 # overridden by the environmental variable.
 PID_FILE_PATH="@runstatedir@/@PACKAGE@/"
-if [ -n "${KEA_PIDFILE_DIR+x}" ]; then
+# Use ${var+x} to test if ${var} is defined.
+if test -n "${KEA_PIDFILE_DIR+x}" && test -n "${KEA_PIDFILE_DIR}"; then
     PID_FILE_PATH="${KEA_PIDFILE_DIR}"
 fi
 
@@ -470,6 +472,7 @@ get_log_messages() {
     fi
     _GET_LOG_MESSAGES=0
     # If log file is not present, the number of occurrences is 0.
+    # Use ${var+x} to test if ${var} is defined.
     if test -n "${LOG_FILE+x}" && test -s "${LOG_FILE}"; then
         # Grep log file for the logger message occurrences and remove
         # whitespaces, if any.
@@ -536,35 +539,36 @@ cleanup() {
     kill_processes_by_name "kea-lfc"
 
     # Remove temporary files.
-    if test -n "${LOG_FILE+x}"; then
+    # Use ${var+x} to test if ${var} is defined.
+    if test -n "${LOG_FILE+x}" && test -n "${LOG_FILE}"; then
         rm -rf "${LOG_FILE}"
         rm -rf "${LOG_FILE}.lock"
     fi
     # Use asterisk to remove all files starting with the given name,
     # in case the LFC has been run. LFC creates files with postfixes
     # appended to the lease file name.
-    if test -n "${LEASE_FILE+x}"; then
+    if test -n "${LEASE_FILE+x}" && test -n "${LEASE_FILE}"; then
         rm -rf "${LEASE_FILE}"*
     fi
-    if test -n "${CFG_FILE+x}"; then
+    if test -n "${CFG_FILE+x}" && test -n "${CFG_FILE}"; then
         rm -rf "${CFG_FILE}"
     fi
-    if test -n "${DHCP4_CFG_FILE+x}"; then
+    if test -n "${DHCP4_CFG_FILE+x}" && test -n "${DHCP4_CFG_FILE}"; then
         rm -rf "${DHCP4_CFG_FILE}"
     fi
-    if test -n "${DHCP6_CFG_FILE+x}"; then
+    if test -n "${DHCP6_CFG_FILE+x}" && test -n "${DHCP6_CFG_FILE}"; then
         rm -rf "${DHCP6_CFG_FILE}"
     fi
-    if test -n "${D2_CFG_FILE+x}"; then
+    if test -n "${D2_CFG_FILE+x}" && test -n "${D2_CFG_FILE}"; then
         rm -rf "${D2_CFG_FILE}"
     fi
-    if test -n "${CA_CFG_FILE+x}"; then
+    if test -n "${CA_CFG_FILE+x}" && test -n "${CA_CFG_FILE}"; then
         rm -rf "${CA_CFG_FILE}"
     fi
-    if test -n "${NC_CFG_FILE+x}"; then
+    if test -n "${NC_CFG_FILE+x}" && test -n "${NC_CFG_FILE}"; then
         rm -rf "${NC_CFG_FILE}"
     fi
-    if test -n "${KEACTRL_CFG_FILE+x}"; then
+    if test -n "${KEACTRL_CFG_FILE+x}" && test -n "${KEACTRL_CFG_FILE}"; then
         rm -rf "${KEACTRL_CFG_FILE}"
     fi
 }
index 5af81084f9f9989cb73623e3f380452d8d2df398..58978bd2c8b4ad59423410a3684484f3abe81eed 100644 (file)
@@ -30,7 +30,7 @@ set -eu
 
 exit_code=
 
-while [ -n "${1+x}" ]
+while test "${#}" -gt 0
 do
     option=${1}
     case ${option} in