From a7ea4aef5090b38f1310b4c9a33de4b0527015a2 Mon Sep 17 00:00:00 2001 From: Aaron Kollasch Date: Mon, 28 Apr 2025 18:15:27 -0400 Subject: [PATCH] Fix tmux_ram_info bug Occurs with lines too long that get truncated, causing unclosed parentheses and breaking the sed regex. The -l option fixes this. -T is for removing unnecessary PIDs (thread PIDs) from pstree output. --- scripts/tmux_ram_info.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/tmux_ram_info.sh b/scripts/tmux_ram_info.sh index 63d4cf03..435e7b73 100755 --- a/scripts/tmux_ram_info.sh +++ b/scripts/tmux_ram_info.sh @@ -67,7 +67,7 @@ get_tmux_ram_usage() case $(uname -s) in Linux) if command -v pstree > /dev/null; then - pids="$(pstree -p "$pid" | tr -d '\n' | sed -rn -e 's/[^()]*\(([0-9]+)\)[^()]*/\1,/g' -e 's/,$//p')" + pids="$(pstree -Tlp "$pid" | tr -d '\n' | sed -rn -e 's/[^()]*\(([0-9]+)\)[^()]*/\1,/g' -e 's/,$//p')" else pids="$(get_cpids_linux "$pid" | tr '\n' ',')" fi @@ -76,7 +76,7 @@ get_tmux_ram_usage() Darwin) if command -v pstree > /dev/null; then - pids="$(pstree "$pid" | sed -En 's/[^0-9]+([0-9]+) .*/\1/p' | tr '\n' ',')" + pids="$(pstree -w "$pid" | sed -En 's/[^0-9]+([0-9]+) .*/\1/p' | tr '\n' ',')" else pids="$(get_cpids_unix "$pid" | tr '\n' ',')" fi @@ -86,7 +86,7 @@ get_tmux_ram_usage() FreeBSD) # TODO check FreeBSD compatibility if command -v pstree > /dev/null; then - pids="$(pstree "$pid" | sed -En 's/[^0-9]+([0-9]+) .*/\1/p' | tr '\n' ',')" + pids="$(pstree -lp "$pid" | sed -En 's/[^0-9]+([0-9]+) .*/\1/p' | tr '\n' ',')" else pids="$(get_cpids_unix "$pid" | tr '\n' ',')" fi