From: Andrei Pavel Date: Fri, 11 Dec 2020 14:23:27 +0000 (+0200) Subject: [#1574] ${var+x}, ${var-x} changes X-Git-Tag: Kea-1.9.3~27 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e2f4e55cd59d2c49855e34ef8857f7545bcb3385;p=thirdparty%2Fkea.git [#1574] ${var+x}, ${var-x} changes --- diff --git a/src/bin/admin/kea-admin.in b/src/bin/admin/kea-admin.in index 57a0dba66f..206ca5e68d 100644 --- a/src/bin/admin/kea-admin.in +++ b/src/bin/admin/kea-admin.in @@ -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 diff --git a/src/lib/testutils/dhcp_test_lib.sh.in b/src/lib/testutils/dhcp_test_lib.sh.in index 67b20a167d..161bfa4d8a 100644 --- a/src/lib/testutils/dhcp_test_lib.sh.in +++ b/src/lib/testutils/dhcp_test_lib.sh.in @@ -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 /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 } diff --git a/src/lib/util/tests/process_spawn_app.sh.in b/src/lib/util/tests/process_spawn_app.sh.in index 5af81084f9..58978bd2c8 100644 --- a/src/lib/util/tests/process_spawn_app.sh.in +++ b/src/lib/util/tests/process_spawn_app.sh.in @@ -30,7 +30,7 @@ set -eu exit_code= -while [ -n "${1+x}" ] +while test "${#}" -gt 0 do option=${1} case ${option} in