From 422c01870a51b863a1ae28fa048c7b9e03fadb80 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Wed, 6 Mar 2024 15:33:38 +0800 Subject: [PATCH] Optimize script logs --- scripts/lib/util.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/scripts/lib/util.sh b/scripts/lib/util.sh index bf636fd45..66e96c1dd 100755 --- a/scripts/lib/util.sh +++ b/scripts/lib/util.sh @@ -409,17 +409,19 @@ for process_name in "$@"; do # Check if any process IDs were found if [[ ${#pids[@]} -eq 0 ]]; then - not_started+=($process_name) + not_started+=("$process_name") else # If there are PIDs, loop through each one for pid in "${pids[@]}"; do local command=$(ps -p $pid -o cmd=) local start_time=$(ps -p $pid -o lstart=) - local port=$(get_port $pid | tr -d '\n') # Use `tr` to remove newline characters + local port=$(get_port $pid | tr -d '\n') # Remove newline characters - # Check if port information was found for the PID + # Ensure port information is followed by a space for separation if [[ -z $port ]]; then - port="N/A" + port="N/A " + else + port="$port " # Add a trailing space for separation fi started+=("Process $process_name - Command: $command, PID: $pid, Port: $port, Start time: $start_time")