diff --git a/scripts/check-all.sh b/scripts/check-all.sh index 48c38331d..7b53e4a89 100755 --- a/scripts/check-all.sh +++ b/scripts/check-all.sh @@ -30,16 +30,18 @@ OPENIM_VERBOSE=4 openim::log::info "\n# Begin to check all openim service" +# Elegant printing function # Elegant printing function print_services_and_ports() { - local -n service_names=$1 - local -n service_ports=$2 + local service_names=("$@") + local half_length=$((${#service_names[@]} / 2)) + local service_ports=("${service_names[@]:half_length}") echo "+-------------------------+----------+" echo "| Service Name | Port |" echo "+-------------------------+----------+" - for index in "${!service_names[@]}"; do + for ((index=0; index < half_length; index++)); do printf "| %-23s | %-8s |\n" "${service_names[$index]}" "${service_ports[$index]}" done @@ -50,11 +52,10 @@ print_services_and_ports() { # Similarly for OPENIM_DEPENDENCY_TARGETS and OPENIM_DEPENDENCY_PORT_TARGETS # Print out services and their ports -print_services_and_ports OPENIM_SERVER_NAME_TARGETS OPENIM_SERVER_PORT_TARGETS +print_services_and_ports "${OPENIM_SERVER_NAME_TARGETS[@]}" "${OPENIM_SERVER_PORT_TARGETS[@]}" # Print out dependencies and their ports -print_services_and_ports OPENIM_DEPENDENCY_TARGETS OPENIM_DEPENDENCY_PORT_TARGETS - +print_services_and_ports "${OPENIM_DEPENDENCY_TARGETS[@]}" "${OPENIM_DEPENDENCY_PORT_TARGETS[@]}" # OpenIM check echo "++ The port being checked: ${OPENIM_SERVER_PORT_LISTARIES[@]}" @@ -91,4 +92,4 @@ else echo "++++ Check all openim service ports successfully !" fi -set -e \ No newline at end of file +set -e