Skip to content

Commit f7c3222

Browse files
committed
feat: improve Separator blank line output 💅
1 parent e2aab59 commit f7c3222

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

bin/show-busy-java-threads

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ isNaturalNumber "$update_count" || die "update count($update_count) is not a nat
303303
readonly update_count
304304

305305
if [ -n "$pid_list" ]; then
306-
pid_list=${pid_list//[[:space:]]} # delete white space
306+
pid_list=${pid_list//[[:space:]]/} # delete white space
307307
isNaturalNumberList "$pid_list" || die "pid(s)($pid_list) is illegal! example: 42 or 42,99,67"
308308
fi
309309
readonly pid_list
@@ -562,6 +562,7 @@ printStackOfThreads() {
562562
}
563563
}
564564

565+
((idx > 1)) && normalOutput
565566
blueOutput "[$idx] Busy($pcpu%) thread($threadId/$threadId0x) stack of java process($pid) under user($user):"
566567

567568
if [ -n "$mix_native_frames" ]; then
@@ -579,10 +580,7 @@ printStackOfThreads() {
579580
/^$/d; p # delete end separator line
580581
}"
581582
fi
582-
{
583-
sed "$sed_script" -n -r "$jstackFile"
584-
echo
585-
} | tee ${append_file:+-a "$append_file"} ${store_dir:+-a "$store_file_prefix$PROG"}
583+
sed "$sed_script" -n -r "$jstackFile" | tee ${append_file:+-a "$append_file"} ${store_dir:+-a "$store_file_prefix$PROG"}
586584
done
587585
}
588586

@@ -594,7 +592,10 @@ main() {
594592
local update_round_num
595593
# if update_count <= 0, infinite loop till user interrupted (eg: CTRL+C)
596594
for ((update_round_num = 0; update_count <= 0 || update_round_num < update_count; ++update_round_num)); do
597-
((update_round_num > 0)) && sleep "$update_delay"
595+
((update_round_num > 0)) && {
596+
sleep "$update_delay"
597+
normalOutput
598+
}
598599

599600
[[ -n "$append_file" || -n "$store_dir" ]] && headInfo |
600601
tee ${append_file:+-a "$append_file"} ${store_dir:+-a "$store_file_prefix$PROG"} >/dev/null

0 commit comments

Comments
 (0)